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

I also have nothing showing up in the preview?

Entering all the code and the preview just shows a blank page with a blank box. No alerts, no text. I've read through the people asking the same question below but none of those solutions seemed to help... here's my code: alert("hello"); document.write(<h1>"Welcome"</h1>); alert("thank you!");

4 Answers

Do you have those commands within a set of script tags in the body of the document like this?

<body>
<script>
alert("hello"); 
document.write("Welcome"); 
alert("thank you!");
</script>
</body>
Javier Alvarado
Javier Alvarado
16,060 Points

Did you save before you hit the preview button? I didn't see anything either until I saved the file. Make sure there isn't an orange dot by the file name so you know that it's saved.

Daniel Mejia
Daniel Mejia
12,481 Points

You need to add the h1 tag to the "document.write" code.

document.write("<h1>Welcome to JavaScript Basics</h1>");

Edit: You're right Marcus Parson, I missed that. Thank you! :)

Adding any kind of HTML tags to document.write() won't help if the text doesn't show up, Daniel.

Calum Hartley
Calum Hartley
6,959 Points

It didn't work for me the first time because I realised that javascript is case sensitive. So Document.write didn't work but document.write did work.

It prompts you with the capitalised version.