Atom doesn't support prompt()?

#1

I’m writing my first Javascript program and receiving an error in the console. I’m wondering if anyone can help me!

Uncaught Error: prompt() is and will not be supported.
at window.prompt (/Applications/Atom.app/Contents/Resources/electron.asar/renderer/window-setup.js:146:11)
at file:///Users/username/Desktop/script.js:1:17

let firstName = prompt("What is your first name?");
let lastName = prompt("What is your last name?");
let age = prompt("What is your age?");
console.log("Your name is " + firstName + " " + lastName + ".");
console.log("You are " + age + " years old.");
#2

Are you typing this into Atom’s developer tools console? If so, that is not the way to run your own JavaScript. Atom’s internal JS is for packages to interact with the different parts of the editor. If you want to run your own scripts for testing, I recommend installing Node.js. That will give you access to a command-line invocation to run your JS without needing a browser, and there are packages for Atom that have the ability to hook into command-line tools like node, so with the right setup you can run any script right from your editor window. Some of the script-running packages spawn a static view and have no idea how to request the user for input, but some packages can be used to tell Atom, “Open a terminal window with this script running in it.”

1 Like