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

console.log start and end. Why?

Hi all,

I kind of understand why we use the console in the developper's tools. To check misprints, typos, and to help us debug.

Why do we need to start our .JS file with console.log("start program"); and end it with console.log("end program"); ? this I don't really get, and i dont understand what it actually does.

Also, on my chrome, I can check the console with the short cuts or going through the path that he showed us, but I dont have that specific JS console. is that normal?

thanks for your help !

1 Answer

Hey, what's going on Raphael!

The reason you start the program and end the program with console.log(""); is to get you into the habit of using console.log(""); to see what is going on inside your program. Basically, you're saying, "Hey, I want you to tell me what is going on right here when the program is running!" For example, say you make a forum where people want to sign up for your blog and on that forum there is a submit button so they can send all their info to you, but it's not working. You would use console.log(signUpButton); to see why it's not working in the JavaScript console and go back and fix the issue. But, you'll learn more of that in later stages. In the case of the video or the current program that you're on right now, the JavaScript console is letting you know that your program has started and ended because you used console.log("start program"); at the beginning and console.log("end program"); at the end.

You might have a newer version of chrome than the one that was on the video which could explain why it is displayed differently. As long as you are able to use the console, you should be ok.

Hope that helps!