Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

141
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!