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

178
Views
How to display record roll and attempts same time?

I got this little dice game and i display roll attempts at each game session but i also want to display "record score", which will be in local storage. how could i make that?

  const [score, setScore] = useState(0)
   function updateScore() {
    setScore(prevScore => {
      return prevScore + 1
    })
  }
<Button rollDice={rollDice}>{tenzies ? "New Game" : "Roll"}</Button>
      <div>Roll attempts: {score} </div>
      <div>Record: {score} </div>

  function rollDice() {
    if (!tenzies) {
      updateScore()
      setDice(prevDice => {
        return prevDice.map(dice => {
          return dice.isSaved
            ? dice
            : generateDice()
        })
      })
    } else {
      setTenzies(false)
      setDice(allNewDice())
      setScore(0)
    }
  }

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!