prompt()
method
The
prompt(message) method opens a pop-up dialog with message
displayed and waits for the user to enter information into the text field of
the pop-up window.
By adding a <span>
element to the heading like this:
<h1>Hello <span id="name"></span>! </h1>
And then putting the following little two line script at the bottom script:
let userName = prompt("What's your name? "); document.getElementById("name").innerHTML = userName;
The will ask (prompt) the user for their name, and then put a personalized hello message to them in the heading.