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 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,520 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.