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 trialCharlie Kloppenburg
5,060 PointsI'm getting an error message in the first Javascript challenge.
Here is the code: <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JavaScript Basics</title> </head> <body> <script> alert("Warning!") </script> <script> document.write("welcome to Javascript"); </script> </body> </html>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JavaScript Basics</title>
</head>
<body>
<script>alert("Warning!")</script>
<script>document.write("welcome to Javascript");</script>
</body>
</html>
3 Answers
Charlie Kloppenburg
5,060 PointsSeriously,
Thanks for the help.
I'll say nice things about you.
Marcus Parsons
15,719 PointsHey Charlie,
I'm not quite sure where you got the "document.write" command from, but the challenge only asks you for an alert box. Just delete that last line, and the challenge will pass.
Charlie Kloppenburg
5,060 Pointsthe alert "Warning!" line passed. Then, it asks to add a second statement. That is where the document.write line came from. Each line seems okay; but when I combine them I get the error message that the first line (whichever one) is now incorrect.
Marcus Parsons
15,719 PointsI loaded up the challenge twice already and there are only two tasks. The first is to create the script tags and the second is to add the alert box. The next challenge has nothing to do with document.write either, so you must be thinking of a different challenge...
Charlie Kloppenburg
5,060 PointsFirst, thanks for the help on this. Here is the challenge and my code that I can't figure out. Sorry about the length.
Challenge Task 1 of 2
Add a pair of script tags inside the body of the page.
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JavaScript Basics</title>
</head>
<body>
</body> </html>
I do this: <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JavaScript Basics</title> </head> <body> <script> document.write("welcome to Javascript") </script> </body> </html>
I get a "Well Done!"
Second part of the challenge is: Open an alert dialog with the message 'Warning!
I do this:
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JavaScript Basics</title> </head> <body> <script> document.write("welcome to Javascript") </script> <script> alert("Warning!") </script> </body> </html>
And, I get the error message: "Oops! It looks like Task 1 is not longer passing.
Thoughts?
Marcus Parsons
15,719 PointsYou only need to add in the script tags exactly as the task asks you to do. "document.write" has nothing to do with this so leave it out completely. So, the first task only wants this:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JavaScript Basics</title>
</head>
<body>
<script></script>
</body>
</html>
And then you just simply add in an alert box in between the script tags you placed in the first task for the second task:
<script>alert("Warning!");</script>
Marcus Parsons
15,719 PointsMarcus Parsons
15,719 PointsI'm guessing it must have worked! hahaha
Marcus Parsons
15,719 PointsMarcus Parsons
15,719 PointsJust keep in mind that the Challenges on here are very finicky about what you can put into code, regardless of whether it might be valid or not. If you only do what the challenge asks you to do, you'll pass 'em every time! :)