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 trialDani C
208 PointsCodes not working.
Hey there. I wrote the following code into script.js, saved it, then previewed. Nothing happened. What am I doing wrong?:
alert(“Hello”); document.write(<h1>Welcome</h1>); alert(“Thanks.”);
2 Answers
Steven Parker
231,275 PointsPeter's right, but perhaps a bit more explanation is in order.
It looks like you composed your code using an editor intended for documents and not for code. The quotes you have are the kind where the left one and the right one use different characters and they look a bit different.
The quote character used for coding has just one form and is used on both sides. You may need a different editor, or just use the one built into workspaces.
Here's your code redone with the standard code quotes:
alert("Hello"); // note the difference from “Hello”
document.write("<h1>Welcome</h1>");
alert("Thanks.");
Dani C
208 PointsPeter + Steven,
Thank you! It works now. You guys are awesome. :)
Peter Hatzer
20,837 PointsPeter Hatzer
20,837 PointsHi Dani,
You have the wrong quotes around the string.
instead of: alert(“Hello”);
Should be:
alert("Hello");
Plus you also need quotes around the document.write("<h1>Welcome</h1>");
Hope this helps.