+ 1
JS localStorage help.
Thereās prompt(āName pleaseā); User puts in name. And clocks on. Now I want to store that value in a localStorage. So next time user comes back he doesnāt need to enter name again because he has already put a name. https://code.sololearn.com/WR4Blfe3gsmw/?ref=app
3 Answers
+ 3
Ginfio local storage will not work here as you want. It will work on browser.
One more thing you declared dslpy inside if statement so you can't access in else statement.
+ 3
Ginfio Try this on browser
var username = prompt("Enter username");
if (username != '')
localStorage.setItem("username", username);
function displayInfo() {
var username = localStorage.getItem("username");
if (username != '') {
alert (username);
}
}
window.onload = displayInfo;
+ 2
AJ Anant ok.
thank u.
Ill try it