Hi everyone!
I'm just begining on JS so I think my code is not very good.
I'm trying to store the results of my game each time it ends.
unfortunately it doesn't work well all the time. Sometimes I have exactly what I want: one line per recording, sometimes I have tons of wrong datas and I can't find the reason why.
Here is my code so far:
score = {
name: name,
maxTurns: maxTurns,
lowestProbability: lowestProbability * 100 + '%',
totalTurns: totalTurns,
initialProbability: initialProbability,
totalSuccess: totalSuccess,
date: new Date().getTime()
}
let localData = localStorage.getItem('score') + JSON.stringify(score);
localStorage.setItem("score", localData);
thanks in advance for your help!