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 Basics (Retired) Introducing JavaScript Your First JavaScript Program

What`s the difference between alert and document.write ?

Thanks

3 Answers

Leandro Botella Penalva
Leandro Botella Penalva
17,618 Points

Hi Ted,

Alert shows an alert box to the user with a message that the user has to press "Ok" to continue using the website.

The document.write prints something directly to the website and don't require user interaction.

Thank you very much

Christopher Debove
PLUS
Christopher Debove
Courses Plus Student 18,373 Points

Leandro told it all. The best way for you to see the difference is to test it. Open a workspace or try it on your browser console.

Thanks