Ask coding questions

← Back to all posts
alerts and prompts
BSlaven (6)

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.

Answered by TheDrone7 (1900) [earned 5 cycles]
View Answer
TheDrone7 (1900)

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 (106)

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