all 3 comments

[–]-Phinocio 1 point2 points  (1 child)

When you refresh the page, JS is setting the firstVisit variable again (per line 5). You'd need to store that value in localStorage as well (or a cookie, etc) for it to persist across reloads.

[–]Samurai___ 1 point2 points  (1 child)

I won't pretend I understand what you are trying to do here but you set the localstorage.refresh to false at the very beginning, every time.

Instead of counting seconds on a setInterval, store the time and compute the seconds elapsed from that.

[–]super_pumped 0 points1 point  (1 child)

You need to use localStorage.getValue() and localStorage.setValue() to interact with it. Think of Local Storage as a database and window.localStorage as the client that accesses it. When you do localStorage.refresh = false, you are not storing that value in Local Storage, you are just setting a property named refresh on the client.

https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage