Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

Danny Rubio
Danny Rubio
2,546 Points

Random question on displaying the value.

I noticed that you used the alert function but I was wondering if you could use the document.write function?

Bogdan Cabaj
Bogdan Cabaj
16,348 Points

HI Danny,

You can always use console.log() to write out to console (developer tools). Personally I don't use document.write as it messes up with your content on the page.

Thanks, Bogdan

2 Answers

Mike Hickman
Mike Hickman
19,817 Points

Hi Danny,

I'm not sure which point in the Javascript course you're at, so here's a quick overview:

alert("message here") - will pop up a separate alert window

console.log("message here") - will print the message to your terminal/console

document.write("message here") - will insert the message onto the actual html page

If you're asking for a specific test/quiz, you'll have to do it how Treehouse wants, but for your own use you can use whichever method you prefer or need.

Cheers,

Mike

Danny Rubio
Danny Rubio
2,546 Points

I think that works! ** Thanks!**