Ask coding questions

← Back to all posts
alerts and prompts
BSlaven

I am a beginner and learning JavaScript if statements currently. But my alerts do not work. Same thing if I do 'prompt'. It keeps telling me 'alert is not defined' and 'prompt is not defined'. I checked many times everything is written correctly. At least I think so. The code works if I for example use it in Chrome dev tools.
https://repl.it/@BSlaven/Ifizjaveilogickioperatori
Thanks

Answered by TheDrone7 [earned 5 cycles]
View Answer
Voters
BSlaven
Comments
hotnewtop
TheDrone7

It is not working because you have made a node.js repl. Node.jsis like a backend version of Javascript and therefore doesn't support frontend functions like alert and prompt. Try making a HTMl, CSS, JS Repl and do the same thing in it.

Please upvote if it helps.

JackFly26

As Drone said, you are using a node js repl. Switch to a html css js repl and it should work.