prompt is an example of that).
The built-in readline Node.js module could be used to prompt the user and request input. But you can also try inquirer or prompt
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
Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology & like learning technical.