-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)
digs
  • 11
  • 1
  • 3

1 Answers1

0

You can use prompt-sync:

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

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

npm install prompt-sync