-2

So far I've been learning JS (basics) and I've been coding in Sublime. And I used to run the code in the browser. I decided (had to) to switch to VSCode and I am pretty unfamiliar with it. I set up Node and now I am trying to find alternative to prompt().

I used to code like this:

 let x = prompt();

but now I can't use prompt in node. I read some threads about it, but I could not find the answer.

What is the alternative way and how can I use it? For example if I want to store the line I typed in a variable.

I just saw some example in c++. I've been looking for something like cin

5

1 Answer 1

1

Welcome to Stackoverflow.

JavaScript running on the browser has access to the Window object and can use the Window.prompt() function.

However, when your code runs on Node, there is no Window. It does not run on the browser. It runs on a command-line. If you want to understand how to pass arguments to a Node command line app, please check this out.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.