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

i need help on this entire subject.

I am not getting enough help wit the challenges to me the videos are not basic enough.

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

</body>
</html>
shout.js

3 Answers

Charles Kenney
Charles Kenney
15,604 Points

Hi Jonathon,

In order to utilize the javascript code on our webpage, we must first create a script tag referencing the javascript file we want to run. We do this by opening a <script> tag and adding a source (src) property, which will point to our javascript file. We do this in the body so that we can prioritize the loading of the Document Object Model before interacting with it.

  <body>
    <!-- javascript -->
    <script src="shout.js"></script>
  </body>

Then, in our javascript file, we need to write the code to display an alert dialog in the users browser. To do this, we call the alert function (alert()) and pass a string parameter with the message we want to display. In this case, the challenge wants us to say, 'I DID IT!'. So we should add the following code.

alert('I DID IT');

Hope this clears up any confusion, Charles

Thank you very much!!

Vladut Astalos
Vladut Astalos
11,246 Points

In the first task you have to link the 'shout.js' file to 'index.html'. You do this by adding this line just before your closing body tag (</body>)

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

Then for your second task you have to write in your 'shout.js' file a line of code that will open an alert box with the message 'I DID IT!'

alert('I DID IT!');

for the first challenge, write <script src="scripts.js"></script> between the body tag. for the second challenge, open the shout.js tab/file on the top of the page and write " alert('I did it'); "