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 trialAnik Desjardins
Courses Plus Student 246 PointsIn task 1, I inserted to correct code. In task 2, I inserted the correct code (as the alert pops up) but it fails me???
Task 2 says that task 1 is no longer valid. When I try to correct the file in task 1 to match task 2 file, it fails me as well. I'm not understanding what it's asking of me.
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JavaScript Basics</title>
</head>
<body>
</body>
</html>
7 Answers
Steven Parker
231,269 PointsUntil you post your code for analysis, here's a hint to start with .. a number of questions about this challenge have been asked by folks who are adding more than the instructions actually ask for. So be careful of that.
Steven Parker
231,269 PointsNow that I see the code, I can explain what happened.
The challenge asks for one set of script tags, and then to put some code between them. But I see you had two sets of script tags. And the first set ("<script src="shout.js"></script>
") reference an external script file named "shout.js" that is not part of this challenge.
And the second set have the alert
function in them, but it prints "I DID IT". The instructions asked for it to print "Warning!".
And to show your code on separate lines (and without other unintended alterations), use the instructions for code formatting in the Markdown Cheatsheet pop-up below the "Add an Answer" area. Or watch this video on code formatting.
Brandon Benefield
7,739 PointsAlways read your instructions very carefully.
1) Add opening and closing script tags inside the body of the page.
So we add the open and closing script tags to suggest the use of JavaScript
2) Inside the script tags, write a function that will open an alert dialog with the message 'Warning!'
Now we need to write a function
that will call the alert()
method then we call that function
SPOILER ALERT
SPOILER ALERT
SPOILER ALERT
<script>
function alertFunc() {
alert('Warning!');
}
alertFunc();
// or just simply
alert('Warning!');
</script>
Steven Parker
231,269 PointsThat's also a case of writing more than the instructions actually ask for; but in this particular instance, you managed to pass anyway.
I strongly recommend (to Anik and other students) to ignore this spoiler.
Brandon Benefield
7,739 PointsI added in just using the alert method Steven Parker
Steven Parker
231,269 PointsPresenting two different solutions might be confusing, particularly since the first one deviates from the instructions. I'm not a fan of spoilers in general, I think most folks learn much more effectively by solving it themselves with a bit of help.
Anik Desjardins
Courses Plus Student 246 PointsI'm two days old on this thing. So sorry. I will try to figure that out. Thanks for your reply!
Steven Parker
231,269 PointsI'll be happy to help, just show the code that you're submitting when you get the error.
And when posting code to the forum, use the instructions for code formatting in the Markdown Cheatsheet pop-up below the "Add an Answer" area. Or watch this video on code formatting.
Anik Desjardins
Courses Plus Student 246 PointsSo I don't know how but I had passed the previous task. Now onto another challenge task and the same thing happens but I didn't really learn from the first. Task 1 was answered correctly. I move on to task 2. It asked that inside the shout.js I create an alert between the body.
<body> <script src="shout.js"></script> <script> alert("I DID IT") </script>
The pop up alert comes on but the response is "Oops! It looks like Task 1 is no longer passing."
I go back to task 1 but the answer is the same. I pass and return to Task 2 to find myself in the same circle.
Hopefully that clarifies my question of how do I get out of this circle.
Anik Desjardins
Courses Plus Student 246 PointsTo be clear, the above code was on different line items. Not in one live as displayed. I'm not sure why it's showing that way.
Anik Desjardins
Courses Plus Student 246 PointsI guess never mind. I took the test and it now has passed me. I promise I kept answering the same and was careful with spaces, caps, etc. Hopefully I'll find clarity.
Jami Nakashima
Courses Plus Student 338 PointsI'm having the same problem and I've been working on it for two days and getting frustrated. I'm not sure where I'm going wrong. I've looked back at all the examples and they all match. I can get the first task done but can't figure out the second.
<body> <script src ="alerts.js"></script> <script> alert("Warning!")></script>
what am i doing wrong?
Brandon Benefield
7,739 Points@jami Remove your first <script src>
tags and only leave the the one with your alert method.
The way you have it setup at the moment, you're calling two different scripts and that's most likely why you're not passing.
Jami Nakashima
Courses Plus Student 338 PointsI"m still having trouble and i took your advice brandon but it still says something is wrong. it own't let me call the function <script src =alert ("Warning!")></script>
Steven Parker
231,269 PointsYou won't use the "src" attribute here, that's just for loading in scripts from external files.
Your code should go between the starting and ending "script" tags. You had that part right back on Oct 20 but then an extra set of tags was causing a problem.
Steven Parker
231,269 PointsSteven Parker
231,269 PointsThe code shown here is the initial code of the challenge — it doesn't look like you've started yet.
Please show the code that you submit when you experience the issue.