[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: scary pepe 2.png (109 KB, 255x191)
109 KB
109 KB PNG
why isnt this shit working

const myBtn = document.getElementById("myBtn");
const myP = document.getElementById("myP");
let timesClicked = 0;

const getScore = localStorage.getItem("myP", "timesClicked");

myBtn.addEventListener("click", function() {
timesClicked++;
myP.textContent = `Times Clicked: ${timesClicked}`;
localStorage.setItem("myP", "timesClicked");
});

>>
>>106434704
Did you ask chatgpt?
>>
>>106434734
no i use it too much and im trying to figure it out the "correct" way
>>
>>106434745
Yeah I can tell lmao
>>
>>106434784
how?
>>
getSccore is not being used. Remove quotation marks around timesClicked when you're passing it to getItem or setItem
>>
>>106434704
The fuck is getScore for?
>>
>>106434704
>why isnt this shit working
https://developer.mozilla.org/en-US/docs/Web/API/Storage/getItem
https://developer.mozilla.org/en-US/docs/Web/API/Storage/setItem
they even have lil examples
>>
>>106434704
Faggot
    localStorage.setItem("myP", timesClicked);



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.