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
Gabriel Anthony Atienza
339 Pointswhen should I use document.write versus console.log?
Codecademy used console.log whereas here, its used as document.write
2 Answers
Chloe Ami
2,830 PointsI'm pretty new to all this and could be completely wrong but I think console.log is when you want to save something to the console where as document.write is actually putting something on the document for all to see? I'm sure someone who knows for sure will be along shortly though :)
Joel Kraft
Treehouse Guest TeacherWhen you're learning a language, it's really important to be able to see what the values in your program are. Both console.log and document.write show values of variables, the difference is where they place those values. I'm not sure what course you're viewing on Treehouse, but in JavaScript Basics, document.write is used to put values onto a webpage, which can be a little easier to read than the small text in a console.
As you progress in your understanding of JavaScript you'll learn how professionals use these two methods. However, for now, it's enough to know that they are being used to get a clear view into how a JavaScript program works.