4 ms·
Update: This is my project for localStorage. var count = 0; function increaseCounter() { // var count = Number(window.localStorage.getItem("count"
by shivajikobardan 4y ago
Update:
This is my project for localStorage.
var count = 0;
function increaseCounter() {
// var count = Number(window.localStorage.getItem("count"));
count += 1;
window.localStorage.setItem("count", count);
document.getElementById("score").innerHTML = count;
}
function decreaseCounter() {
// var count = Number(window.localStorage.getItem("count"));
count -= 1;
window.localStorage.setItem("count", count);
document.getElementById("score").innerHTML = count;
}
function clearCounter() {
window.localStorage.clear();
count = 0;
document.getElementById("score").innerHTML = "";
}
This code works now. But is there a point of using localstorage if I'm going to do like this? My goal for asking the question was to understand the first line.
[CODE] // var count = Number(window.localStorage.getItem("count"));[/CODE]
I didn't get what we did here and why we did here.