HELP! Kinda confused at my code
So, i've been working on a small project with localStorage, and what I'm trying to do is have the first time the user opens the page, it asks for the name of the user, then if the user closes the tab, and comes back to the page, it will already have written on the page, " your name is ..." But i don't know how to quite do that. Could someone help me? <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="main.css"> <title>My Website</title> </head> <script> function myFunction() { if (localStorage.getItem("objectname")==="null") { var name = prompt("What is your name?") var x = name; localStorage.setItem("objectname" , x); function display() { document.getElementById('p').innerHTML= "Your name is: " + localStorage.getItem("objectname"); } } else { alert("Your name is" + localStorage.setItem("objectname")); } } </script> <body> <button onclick="myFunction()">Run entire code!</button> <br /><br /> <button onclick="display()"> Click Me to change text</button> <p id="p">Your name is: Insert Name</p> </body> </html> *The css stylesheet isn't important