How do I return JavaScript Values in Atom Editor?


#1

Hi,

I have been learning to code web development via the Odin Project and have begun JS basics. However, I have been trying to get the editor to return values to me, however it does not do that. Is there a way to get this done?

As a temporary workaround, I have just been practising code in Google’s developer tools, but would really like to know how to do this for the future.

Here is a screenshot of my code where I would like the variable to be returned. It is in the part of my index.html document.

Also as a second question? What is electron?

Please advise,

Many Thanks.


#2

Atom does not run code on its own. You need to download a package to do that, and which package is best will depend on your needs (script is popular and very basic).

What is electron?

It’s basically Chrome with Node.js strapped to the back. Electron allows for desktop applications to be built in the manner of single-page applications with JS/HTML/CSS as the only code required and is the framework used by Discord and Slack, among others.


#3

In additon to Atom not running code itself, a program does not (in general) print any values unless you explicitly tell it to.

In your case, JS uses console.log to print the value of a variable to the dev tools console. Which dev tools console depends on the context you are running your code in; if the code is part of an Atom package, the dev tools will be the one for Atom. If it’s for an HTML webpage like the above looks like, it will be the dev tools of the page running the HTML.