Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

178
Visualizações
How to Replace Const With Other Valua In Java Script

i have Constanta In Javascript , i want to replace This Value Before Initialitate this conts but not working , i have idea to replacing Const With Other Const but This not Working again

const audioMap = [
    "<?php echo base_url('sounds/Airport_Bell.mp3');?>",
    "<?php echo base_url('sounds/C.wav'); ?>"
];

self.queue.shift();

document.getElementById("list_antrian").innerHTML = JSON.stringify(self.queue);

let audio = new Audio();

function playSequence(sounds) {

    const playNextSounds = (sounds) => {
        if (sounds.length > 0) {
            var audio = new Audio();
            audio.src = sounds[0];
            audio.currentTime = 0;
            audio.play();
            sounds.shift();
            audio.addEventListener('ended', function () {
                return playNextSounds(sounds);
            })
        } else {
            self._call();
        }
    }

    let currentSoundIndex = 0;

    if (sounds.length > 0) {
        const audio = new Audio();
        audio.src = sounds[0];
        audio.currentTime = 0;
        audio.play();
        sounds.shift();

        audio.addEventListener('ended', function () {
            return playNextSounds(sounds);
        })
    } else {
        self._call();
    }

}

playSequence([
    "<?php echo base_url('sounds/A.wav'); ?>",
    "<?php echo base_url('sounds/B.wav'); ?>",
    "<?php echo base_url('sounds/C.wav'); ?>"
]);

I want Change playSequence With audioMap

Thanks

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

use let when mutating, const when it's constant.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const

You can merge those array's together, like in the following, if you're trying to just bring in audioMap and the array currently being passed into playSequence

const audioMap = [
  "<?php echo base_url('sounds/Airport_Bell.mp3');?>",
  "<?php echo base_url('sounds/C.wav'); ?>"
];
const audioSet = [
  "<?php echo base_url('sounds/A.wav'); ?>",
  "<?php echo base_url('sounds/B.wav'); ?>",
  "<?php echo base_url('sounds/C.wav'); ?>"
]
playSequence([...audioSet, ...audioMap]); 

You can also mutate the array, but I recommend the approach above.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda