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 trial

JavaScript JavaScript Basics (Retired) Introducing JavaScript Link to an External Script

pamela guy
PLUS
pamela guy
Courses Plus Student 4,311 Points

Can someone tell me why this is not working?

Why is this not working help please?

index.html
<!DOCTYPE HTML>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JavaScript Basics</title>
</head>
<body>
  <script>alert("I DID IT");</script>

</body>
</html>
shout.js
alert( 'I DID IT!');

3 Answers

You need to add a way to load the shout.js file into the index.html file.

In order to do this you are going to want to add the html tag script:

<script></script>

Next you will want to link the shout.js file by adding the src attribute to the script tag:

<script src="javascriptFileName.js"></script>

Hint: Replace javascriptFileName.js with shout.js

Justin Radcliffe
Justin Radcliffe
18,987 Points

Hi Pamela,

You don't need to duplicate the alert() function in both files. Just keep the one in the .js file as you currently have it. Then you need to link to the shout.js file inside the index.html file as Joe Beltramo mentions above.

Mohammed Nokri
Mohammed Nokri
931 Points

can fix it by using the <script> tag to include js file in your page, and delete other one in the body

<head> ... <script src="javascriptFileName.js"></script> ... </head>

The challenge specifically asks for the script tag to be placed in the body. So unfortunately your solution would not pass the challenge requirements.