Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

147
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda