var name = window.prompt("What is your name?"); document.write(name);
- Here, we have created a variable and I have given a variable name as “name”.
- Actually set this variable equal to a special value as “window.prompt”. And basically, this is going to prompt the user to give us specific information. Whenever information the users give us is going to store inside of variable “name”.
- Inside the prompt parentheses, we can actually type a message for the user. So, I have given “what is your name” inside the parentheses. Basically have a prompt box that prompts the user to give us their name.
- Then we printed the “name” using document.write().