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

144
Visualizações
I am making a mancala game; and need help figuring out how to move the 'marbles' to each hole. Im figuring an if statement is the way to go but lost

This is what i have so far. i am able to target the pits and the seeds itself. My 'seeds' are just a number displayed in the pits.I have not targeted the storage yet so maybe i should define a variable that can. Im able to get the next pits number updated but the ones following do not update

   /// event listener to hear pits clicked
    allPits[i].addEventListener('click', () => {
        ///  targeting pits indivually but also the seeds amount within
        let currentSeeds = allPits[i].dataset.seed
        // hitting and changing hardcode html-- 4-4=0 
        allPits[i].innerHTML =  allPits[i].dataset.seed - currentSeeds
         
        console.log('clicked:', allPits[i])
        console.log(allPits[i+1])
        ///interating thru the following pits to add a seed
            allPits[i+1].dataset.seed++
        console.log('add', allPits[i+1].dataset.seed)
        //changing the hardcoded 4 to +1 to add to the next pits seed count
        allPits[i+1].innerHTML = allPits[i+1].dataset.seed
        //for loop to finish out the previous code 
        for(let k = 0; k < currentSeeds; k++){
            console.log('currentseeds', currentSeeds)
            //delivers the +1 seed to next pit
            currentSeeds[k] = allPits[i+k]
        }
    })
}
about 4 years ago · Juan Pablo Isaza
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