prompt() is a user-interface function, it allows us to get a piece of text from user.
prompt() function displays a piece of text as prompt message to the user, then it waits for the user to input some text. The input text is returned as a string by the
title is a string text to show to the user.
let name = prompt("Please enter your name here:"); console.log('Hello, '+ name + '!');
Type your name into the input box then click "OK". Your name will be printed in the console window.
Input a number
Sometimes we need the user to input a number. But the
// prompt user let n = Number(prompt('Enter a number: ')); console.log(n + ' * ' + n + ' = ' + n*n);
If you input
5, the console will show
5 * 5 = 25.