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 Introduction to Programming Basics Variables

Stacy Fabian
Stacy Fabian
2,246 Points

Why all the console.log entries?

In this video he shows doing console.log entries for a bunch of stuff like "Hello from [file name] and "Hello Again". I assume these are to show how to do console.log entries, but then he shows doing an entry with a result different than the prompt entry. Why is that? What is the general purpose/benefit to console.log entries? (I'm sure it's covered later but I think knowing the "why" of it all now will help me understand all the lessons better.)

Thanks!

1 Answer

Ivan Burda
Ivan Burda
10,897 Points

Hi Stacy,

console.log() is used to display something for you as a programmer. Let's say you want to know a value of a variable which changes when the script runS, so you use console.log to print out the variable for you. Console.log has no impact on the visitors of the page but it may be useful for your to check the functionality of the code and understand what is going on for example if something works differently to what you have expected.