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

yousif alyousif
yousif alyousif
2,322 Points

in order to make the "shout.js" work, we must load first "index.htm". can any one please direct me on how to do that ?!

we tryied several things and that was one of the attmepts but sadly it did not work can you please advice me on how can i solve this task ?

index.html
<!DOCTYPE HTML>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <script src="index.html"></script>
  <title>JavaScript Basics</title>
</head>
<body>
  <div w3-include-html="index.htm">
  <script src="shout.js"></script>
  </div>

</body>
</html>
shout.js

yousif alyousif
yousif alyousif
2,322 Points

this is the instruction for the first step: There are two files: a web page, index.html, and a JavaScript file, shout.js. To run any programming in the shout.js file, you first need to load it into the index.html file. Add the required HTML to load the external JavaScript file into the web page. Make sure to add your code inside the <body> of the page.

yousif alyousif
yousif alyousif
2,322 Points

and this is the instruction on the secound step: Inside the shout.js file, write the code for an alert dialog with the message 'I DID IT!' the problem is even if i remove the div part it says (Oops! It looks like Task 1 is no longer passing.) !!! and i can not pass it

nico dev
nico dev
20,364 Points

Yes, thank you for your reply and explanation of the challenges.

I see. But my additional question, too, was what exactly and literally are you typing in the second step.

And my question 2 was where are you typing it (i.e.: in the html file or in the shout.js file)?

yousif alyousif
yousif alyousif
2,322 Points

thanks for your replay guys i felt so stupid for that mistake sorry xD thanks for you help Nico

nico dev
nico dev
20,364 Points

Exactly! That's the reason you linked to it with the script tags in the html file, remember? Somehow, that was like telling to the html: 'Hey, look, I want to use the scripts that you'll find in the file shouts.js'. :)

And, by the way, make sure to check the instructions about exactly how you have to write the word (things like capital letters or non-caps, etc. are essential to make it through).

nico dev
nico dev
20,364 Points

No problem, glad to help, we're all in the same boat. I also get stuck everyday. :)

And, by the way, just in case anyone else has the same problem in the future and can find a way out, do you mind marking Steven's as best answer? That will help solve future similar problems.

1 Answer

Steven Parker
Steven Parker
229,732 Points

You did more than was asked for.

Your <script> code is fine, but the instructions didn't say anything about adding a <div> element with a fancy attribute. Where did that come from?

yousif alyousif
yousif alyousif
2,322 Points

Well that was me trying to solve the problem but sadly it did not work and if i remove the div line it works but if i go to the secound step it refers me back to this one and says you did not link the "index.htm" file which the instruction says it should load first !

nico dev
nico dev
20,364 Points

Yes, it's just like Steven said.

Just a question, where and what are you typing in that second step you mention, yousif alyousif ?

Sometimes it brings you back to the first one, even though the error is actually in the second one.