js get input from user 1

js get input from user

var name = window.prompt("What is your name");
document.write("Hello " + name);

Here is what the above code is Doing:
1. We are creating a variable called name and assigning it the value of the result of the prompt function.
2. We are then using the document.write function to write the string “Hello ” and the value of the name variable to the page.

Similar Posts