Ask coding questions

← Back to all posts
Error
WilliamXing (50)

Why does it say NaN in cookie clicker?

Comments
hotnewtop
InvisibleOne (2931)

Because cookies is Not A Number. I think that localStorage can always find the item your looking for, it will just return a null or NaN value. Maybe try using an if statement to verify

if (parseInt(window.localStorage.getItem('cookies'))) {
  cookies = window.localStorage.getItem('cookies')
} else {
  cookies = 0;
}
ch1ck3n (2027)

add var cookies; to the start of main.js

firefish (947)

add var cookies; to the start of main.js

@ch1ck3n cough don't you mean let cookies;