Skip to content

Commit 9daf3b1

Browse files
committed
Fix a bug where highscore did not save on first game.
1 parent d3a1fae commit 9daf3b1

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎js/snake.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ SNAKE.Snake = SNAKE.Snake || (function() {
329329
me.handleDeath = function() {
330330
function recordScore () {
331331
var highScore = localStorage.jsSnakeHighScore;
332-
if (highScore == undefined) highScore = me.snakeLength;
332+
if (highScore == undefined) localStorage.setItem('jsSnakeHighScore', me.snakeLength);
333333
if (me.snakeLength > highScore) {
334334
alert('Congratulations! You have beaten your previous high score, which was ' + highScore + '.');
335335
localStorage.setItem('jsSnakeHighScore', me.snakeLength);

0 commit comments

Comments
 (0)