I'm writing a code but replit is throwing error

Question: I’m writing a code but replit is throwing error and I have tried codes which used to work in past even they are also not working.

Repl link: https://replit.com/@SatyamSingh152/practiveseteverything-1#index.js

code snippet let n = prompt("Enter the value of n")
n = Number.parseInt(n)

let i = 10;
}while (i < n) 

Guys someone please help.

I’m getting this error in replit even though I have tried copy pasted codes from google, but it looks like the issue is with replit.

 node index.js
let n = prompt("Enter the value of n");

ReferenceError: prompt is not defined
at Object. (/home/runner/practiveseteverything-1/index.js:1:9)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47

Can you try this:

You’ll need to use the prompt-sync library.


Thank you very much! It worked for me too.

1 Like

Hi @SatyamSingh152 !
Since @KAlexK 's post answered your question, could you mark their post as a Solution?

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.