Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript and the DOM (Retiring) Getting a Handle on the DOM Using CSS Queries to Select Page Elements

terry okey
terry okey
3,187 Points

Why put code into the console?

In this and a few past videos, why are we putting the instructions (that seem to be JS coding) into the console? Shouldn't all that coding be in the .JS file? And when you put it into the console where does the code live? I know that we have been working with three files in a master folder: the HTML, CSS, and .JS files. And that makes sense to me, that master folder could be somehow connected to the site we are trying to program. But I don't understand where the console stuff lives, and does it always just run once, or does it stay around somewhere? Any general descriptions on this are appreciated.

HI terry okey ,

The code written in console is live to that console only till the page reloads.The practice of writing code in console is mostly used when we're testing something is working fine or not before writing the code in JS file.

Hope it clears your doubt.

1 Answer

terry okey
terry okey
3,187 Points

Thank you that makes perfect sense!