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

<body> <script> src="shout.js"</script></body> Returns a no "src" error code?

Lesson quiz asks to link external Javascript file within html body tags. Here is the code I wrote:

... <body>

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

</body>

The error I get is to use the "src" which is in the code? Any ideas on what I'm doing wrong?

index.html
<!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"</script>
</body>
</html>
shout.js
alert("Test Message");

2 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,858 Points

HI Emir,

The src="shout.js" is an attribute that needs to be a part of the script tag. Right now, you have it between the tags. So it should look like this:

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

Notice where the closing > is placed for the opening <script> tag.

Also, if this is for the first challenge, the instructions did not ask for anything to be inside of the shout.js file yet. I'm not sure if it makes a difference for this specific challenge, but most challenges will fail when you add something not asked for.

Keep Coding! :) :dizzy:

Thanks Jason! :)