Usage of prompt

suggest change

Prompt will display a dialog to the user requesting their input. You can provide a message that will be placed above the text field. The return value is a string representing the input provided by the user.

var name = prompt("What's your name?");
console.log("Hello, " + name);

You can also pass prompt() a second parameter, which will be displayed as the default text in the prompt’s text field.

var name = prompt('What\'s your name?', ' Name...');
console.log('Hello, ' + name);

Parameter Description
message Required. Text to display above the text field of the prompt.
default Optional. Default text to display in the text field when the prompt is displayed.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents