Open esto30 opened 6 months ago
same error bro
Which browser and which version you are using???
It seems a browser behavior error which return undefined
instead of null
when the searched storage item does not exist yet
microsoft edge and latest version
Try to change this line :
let scores = JSON.parse(localStorage.getItem('scores')) || { wins: 0, losses: 0 };
into
let scores = JSON.parse(localStorage.getItem('scores')||null) || { wins: 0, losses: 0 };
I couldn't understand this error //// Uncaught SyntaxError: "undefined" is not valid JSON at JSON.parse ()
at 10-rock-paper-scissor copy.html:43:27 ////
let scores = JSON.parse(localStorage.getItem('scores')) || { wins:0, losses:0, ties:0 }; . . . . localStorage.setItem('scores', JSON.stringify(scores));