0

The prompt statement in JavaScript (not Web JavaScript) is supposed to return a > prompting the user to enter a string. Here is my code:

var i;
while(i == i) {
    var input = prompt();
}

Yet this is the output: undefined> Is there a reason this is happening?

2 Answers2

0

Its saying undefined because there is no text inside prompt use

   Var input = prompt(' ');

It will generate a prompt with no question.

Also if you are using Node js then it will not work because prompt is part of Vanilla Js not Node js.

Karan Singh
  • 183
  • 1
  • 9
0

Use readline, prompt, or prompts. prompt/prompts is very easy to use, readline is more advanced.