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 trialRobert Booth
2,290 PointsHow to open an alert dialog box after passing Task 1?
I passed the first task by adding a pair of scripts but everytime I try to add the alert dialog box it no longer passes the first task. What am I doing wrong?
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JavaScript Basics</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
2 Answers
Eric Trego
15,308 Pointsto open an alert dialog box in the index.html you will need.
<script>
alert("what ever you want to alert");
</script>
if you are in a js file then it would look the same without the <script> tags.
hope this helps
Eric Trego
15,308 Pointsno problem. happy coding
Eric Trego
15,308 PointsEric Trego
15,308 Pointsalso you need to delete the src="script.js" you do not need this in the <script> tag because you are adding the JavaScript right to the html. you only need src="script.js" if you are adding a different file to the index.html page.
Robert Booth
2,290 PointsRobert Booth
2,290 PointsThanks for your response Eric. However, everytime I add this to the code it brings back an error message saying "It looks like Task 1 isn't passing" or "you didn't call the alert function". Am I supposed to be entering the alert dialog box outside the body?
Eric Trego
15,308 PointsEric Trego
15,308 Pointsok so the first task is asking you to insert a script tag in the between the body tag.
Eric Trego
15,308 PointsEric Trego
15,308 Pointssecond task is asking for this insde the script tags
<script>alert('Warning');</script>
make sure you use the cap W the tests are case sensitive if it uses a capitalized letter you have to too.
Robert Booth
2,290 PointsRobert Booth
2,290 PointsOh wow thanks a lot Eric! For some reason I thought the two tasks were correlated so I thought the "script.js" tag needed to be included as well in the second task. This is my first time learning a programming language so I am kind of trying to learn the ropes.