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) 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.