-1

I'm trying to convert some code I wrote in Python to JavaScript, but the Python code used an input() function. Is there a way to get user input through the console in JS?

The Python code was this:

userString = input("Enter a string => ")
answer = getAnswer(userString)
1

1 Answer 1

0

You can use prompt-sync:

const prompt = require('prompt-sync')();

const str = prompt('Enter a string: ');
console.log(str);

npm install prompt-sync

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.