prompt is an example of that).
To write messages to stdout,
console.log() is the simplest native solution (available in both browser and Node.js contexts)
A simple example code gets user input.
<!DOCTYPE html> <html> <body> <script> var name = window.prompt("Enter your name: "); alert("Your name is " + name); </script> </body> </html>
Use this if you want to use confirm, which would give you the equivalent of a Boolean expression.
var answer = confirm("Yes or no?")
Do comment if you have any doubts or suggestions on this Js input topic.
Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.
OS: Windows 10
Code: HTML 5 Version