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 trialvishal chauhan
879 PointsInside the shout.js file, write the code for an alert dialog with the message 'I DID IT!'
what i am doing wrong in this code ...tell me and help please
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JavaScript Basics</title>
</head>
<body>
<script src="shout.js" alert ('I DID IT'!);> </script>
</body>
</html>
<script src="shout.js" alert ('I DID IT'!);> </script>
3 Answers
Gabbie Metheny
33,778 PointsYou have all of the right content, but in too many places! index.html should ONLY have the script tags that load the source:
<body>
<script src="shout.js"></script>
</body>
And shout.js should ONLY have the alert:
alert('I DID IT!');
You're telling index.html to run your JavaScript file (shout.js), which contains the alert command.
Viktor Doska
2,138 PointsIn shout.js you do not need to write
<script src="filename"></script>
it is for html file so that it can implement your script.
In js file just write your code like
alert ('I DID IT'!);
And in .html file just add
<script src="filename"></script>
so that the web page knows where to get your code from
vishal chauhan
879 Pointsyeah thnanks #gabbie ans @victor now i done it
Iagor Moraes
18,678 PointsIagor Moraes
18,678 PointsYou are inserting the function inside of opening SCRIPT tag, its wrong, above is right:
<script src="shout.js"> alert ('I DID IT'!); </script>