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) Storing and Tracking Information with Variables Combining Strings

Ayush Bahuguna
Ayush Bahuguna
2,092 Points

alert and document.write functions are not working.

I have saved the file and I have checked with the code that has been typed by the instructor, but still, document.write() is not printing on page.

4 Answers

Are you sure you are putting quote marks "" around the strings? Eg.

alert("hello");
document.write("hello");
Ayush Bahuguna
Ayush Bahuguna
2,092 Points

I have used single quotes. My code is exactly what the instructor had typed. He got the message printed on the page, but it didn't work for me.

Have you linked the js. file to the index.html file? It's tough to help you without seeing the code.

Ayush Bahuguna
Ayush Bahuguna
2,092 Points

Yes. I have. I have rechecked several times with the instructor's code, but still I can't get it to print on my page.

john teo
john teo
1,779 Points

I had the same problem until I realized that I opened the previous index.html file from the previous video lessons instead of the current one. Maybe you encountered the same mistake?

I think you should show us the code ;)

Ned Redmond
Ned Redmond
5,615 Points

I'm having the same issue.

var visitorName = prompt('What is your NAME?'); var message = "Hello " + visitorName + "! Welcome to Treehouse."; message += " Eat a butt, dirtbag."; document.write(message);

I'm just not seeing anything populate to the page.