problem with prompt in node
When I use prompt("...")
in a nodejs repl, it works.
When my students use prompt("...")
in a nodejs assignment in my course, it doesn't work
The error I get is:
ReferenceError: prompt is not defined
mwilki7
I remember this not working for one of my nodejs
repls.
I solved it by requiring readline-sync
:
var readline = require('readline-sync');
You can get user input like this:
var name = readline.question("What is your name?");
If this doesn't work you might need to install it from the package manager first:
zplusfour
prompt is to take input
and in node.js to make variables you should write let
or var
before writing the name of the variable
prompt
is something REPLit adds to its Node.js runtime environment. It's not part of Node.js itself.