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 trialMari Carter
66 PointsI am entering the right code. Challenge will not pass. Javascript course adding alert message with script tags
<script> alert("Warning!"); </script>
its saying "You didn't call the alert()
function inside the <script>
tags."
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JavaScript Basics</title>
</head>
<script>
alert("Warning!");
</script>
<body>
<script src="scripts.js"></script>
</body>
</html>
7 Answers
Steven Parker
231,236 PointsRight code, but in the wrong place.
It looks like you moved your script tags after task 1. The task 1 instructions said: "Add opening and closing script tags inside the body of the page."
But in the code you have here, the script tags are placed before the body. You also have a second set of script tags to reference an external file that is not part of the challenge. Remove the extra tags and put the original ones back inside to body to pass the challenge.
Steven Parker
231,236 PointsHere's your code rearranged according to my previous comments to pass task 2:
<!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>
</body>
</html>
Task 1 should have been the same but without the alert statement. This challenge does not use the src attribute for the script tag.
Mari Carter
66 PointsIn the first step I entered the opening and closing script in the body of the page and it said it was correct. The second step asked me to enter an alert using script tags that would produce a warning box. I did that and the box even appeared when i checked my work saying "warning" I have entered the scripts alert tags inside the body and it didn't worked, I moved it a couple other places on the page and still the same response "You didn't call the alert() function inside the <script> tags."
Mari Carter
66 PointsInside the script tags, write a function that will open an alert dialog with the message 'Warning!'
thats what the second step it asking
Steven Parker
231,236 PointsYou still need to remove the extra tags that are not part of the challenge.
<script src="scripts.js"></script> <!-- this line should not be here -->
Mari Carter
66 PointsI also removed that line and tried to just submit the script alert tag and it gives me an error saying task 1 is no longer correct. There is a little box that has a reminder saying that tsk two builds off task 1 so it should still be able to appear on the code page in addition to the work they are requesting for task 2.
Mari Carter
66 PointsI read some other forms and others seem to have this same issue on this task
Steven Parker
231,236 PointsI've seen some others also. I think a common mistake is to put a src attribute in the script tag even though the challenge does not ask for one.
Mari Carter
66 PointsI just went back to the challenge and type exactly what you have here under task 2 and its says "oops, look like task 1 is now incorrect" I think I am just going to move pass this task or see if i can get a friend to look at it in person.
Steven Parker
231,236 PointsVery odd. I just cut-and-pasted it directly into the challenge just now and it passed.