Not able to use prompt in replit for js

I am unable to use prompt in repilt for javascript ca anyone suugest me what can i do ?
Repl link:

code snippet

Welcome to Ask! Please provide the link to your Repl and if applicable a screenshot so we can take a look.


sureit is the link to my repl
i have also uploaded the ss of my repl.

Adding const prompt = require('prompt-sync')(); to the very beginning of the program fixed it for me.


In case you were wondering, prompt isn’t a function in Node.js (since prompt in browsers makes a popup, but Node.js is a server so it can’t do popups).

Basically the “requisition” of the module in the solution adds custom functionality for the prompt function, making it ask the question in the console.

1 Like

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