How to use “readline()” function in JavaScript?

How to use “readline()” function in JavaScript?
0

#1
var names = ["David", "Cynthia", "Raymond", "Clayton", "Jennifer"]; putstr("Enter a name to search for: ");
var name = readline();
var position = names.indexOf(name);
if (position >= 0) {
print("Found " + name + " at position " + position);
} else {
       print(name + " not found in array.");
    }


#2

If you are talking about Node’s readline method, then read this.


#3

No, I run into Data Structures and Algorithm with JS books. It was not giving any information about Node’s. I just need help the second line in my sharing code. Thanks


#4

Is this a front-end or back-end project?

If front-end, what are you trying to do with readline in your code?


#5

only the second line. What is the functionality readline in the second line?

var names = ["David", "Cynthia", "Raymond", "Clayton", "Jennifer"]; putstr("Enter a name to search for: ");
var name = readline();
var position = names.indexOf(name);
if (position >= 0) {
print("Found " + name + " at position " + position);
} else {
       print(name + " not found in array.");
    }