Prompt no longer showing when page refreshed?

I’m working through this:
Adding a personalized welcome message

I got the prompt to show once. However, it doesn’t show up again when I refresh the page. Any idea why this is happening?

Hello @bengrieve

if your code same as this one
then it cause the setUserName() called only once cause of the following part of code

if(!localStorage.getItem('name')) {
} else {
  let storedName = localStorage.getItem('name');
  myHeading.innerHTML = 'Mozilla is cool, ' + storedName;

it check of there variable stored in the localStorage with name “name” and since it get saved after the first call to the setUserName by this part of the code
localStorage.setItem('name', myName);

hope that help and have a nice day :slight_smile:

1 Like

I realized afterward that I had myName instead of storedName. Everything else was in working order!

glad to know that you figured it out well done and have a nice day :slight_smile: