I am having trouble in prompt function

my prompt function dont work
Error: prompt is not defind

**Repl link: https://replit.com/@ayushhande2003/ayush-code#index.js

let n = prompt("Enter the value  of n");
n = Number.parseInt(n);
console.log("value of n is " + n);

Welcome to ask, @ayushhande2003!

prompt is a part of web javascript, not nodejs. See this page for a solution: https://www.codecademy.com/article/getting-user-input-in-node-js

If this post solves your question, mark it as the solution!

2 Likes

You can add this line to the beginning of your code:

const prompt=require('prompt-sync')()
4 Likes