Begginer's Question: Practice Exercises: console.log & Variables (exercise 1)

This post was flagged by the community and is temporarily hidden.

I’ve reframed my query, please read, thanks!

You can access a javascript console from a browser. In chrome just open a new window and right click or control click if on a mac.

Screen Shot 2020-10-27 at 19.50.27

You either paste what you have typed in Atom at the > and hit enter or just type it in and hit enter.

console.log is how you output anything to the console to check what is running in your javascript.

e.g. x = 2;
console.log(x);

or

console.log(“Hello”);

As below, I made some mistakes!

Screen Shot 2020-10-27 at 19.55.57

If not using Chrome, search google for how to access the console. Internet Explorer and Edge will be F12.

Hope that helps.

fmjh

1 Like

Forgot to say that you need to choose “Inspect” to see the Developer tools including console!

Thank you,
I’ve been able to make some headway with the first three Practice Exercises: console.log & Variables, by entering everything directly into my Google browser console. However, before I move on to the next set of exercises I really need to ask:

If all this can be done directly on the console, what exactly is the purpose of creating a new file in our code editor (Atom) and saving it as my_script.js???

Thanks again, I appreciate your response!

Basically, the idea is that you know how to create your own JS files, off course all code can be done through the Browser Console (chrome, firefox, brave, etc…), but when you have to not only test code in the console, also keep it, you need to know how to create your own JS files.

Carlos Z

The console is just used for running javascript interactively and debugging. Most of the time scripts are developed and stored in files. It’s a lot easier that typing out the same lines of code over and over again especially when they become more involved.