Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

When i put alert in the shout.js file, src file no longer responds

When i put <script> alert("I did it")</script> in shout.js file, <script src="shout.js"> </script> gets inactive.

  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JavaScript Basics</title>
  <script src="shout.js"> </script>

<script> alert("'I did it'") </script>

2 Answers

28,538 Points

Script tags are only used when embedding JavaScript code within an HTML file. When writing JavaScript code within a JavaScript file you don't use them. Also you don't need both double quotes and single quotes when creating a string. You should go with one or the other.

If you remove the tags from the shout.js file like this:

alert("I did it") // Removed script tags and switched to only using double quotes (")

Then your code will work.

Kyle Johnson
Kyle Johnson
33,528 Points

Hi Ashma!

You have the right code to cause an alert to appear.

alert('I did it!');

But you have extra html tags in your shout.js that shouldn't be there.


Once you remove the script tags and add a semi-colon to the end of the line you will pass the challenge. You're code should look like this in the shout.js:

alert('I did it!');