I am working on a script to identify new visitors to my page, prompt them for their name, and store it using local storage. If the visitor is a returning user, I want to display their name on the page using 'querySelector'.
So far, I have been trying to determine if the user is new or returning, but I've hit a roadblock.
var localStorage = window.localStorage;
if(localStorage.getItem("reutrn_user")) {
//
} else {
var name = prompt("Please enter your name");
localStorage.setItem('username', name);
}
Does anyone have suggestions on how to retrieve the username and display it in case of a returning user?
Thank you!