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 Write Another Program

Franchesca Quezada
Franchesca Quezada
256 Points

Challenge questions: Inside the script tags, write a function that will open an alert dialog with the message 'Warning!'

This is the first time I've ever written code. I've watched the video for these questions over and over and can't seem to get this to work. I always get the first part right, but when I add the second script tag inside, it stops working. What am I doing wrong? Please help! Thanks!

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="scripts.js"></script>
  <script src="app.js"></script>
  <script>
    alert("Warning!");
  </script>
</body>
</html>

1 Answer

andren
andren
28,558 Points

You have the right code, you just also have wrong code.

Challenges are pretty picky, and will often fail you if you do anything beyond the exact thing they tell you to do.

In the first task you are asked to create a pair of script tags, you are not asked to link to a file using those tags. And in the second task you are asked to put code within those tags, not to add any new script tags.

If you remove the two script tags where you link to js files and just keep the last of your tags like this:

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

Then your code will be accepted.