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

peterson st gourdain
peterson st gourdain
931 Points

why cant i add my alert

why cant i add my alert

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>
    alert("warning");
  </script>
</body>
</html>

2 Answers

Steven Parker
Steven Parker
229,732 Points

This is better, the code is now inside the body element. But you still have a line with an extra set of script tags with a src attribute that are not part of this challenge. That line should be removed.

function theAlert() {
      alert("Warning!"); 
    }
theAlert();

I believe this is a duplicated question.

Steven Parker
Steven Parker
229,732 Points

But creating and calling a function is not part of this challenge.

I believe we must be looking at different questions Steven, the one I see has this question: Challenge Task 2 of 2 - Inside the script tags, write a function that will open an alert dialog with the message 'Warning!' - that is a copy-and-paste from the challenge page. Also, I tried my solution before posting it, it works correctly. Cheers.

Steven Parker
Steven Parker
229,732 Points

Yes, I can see that it would indeed pass the challenge, but it's not needed for the challenge or related to the cause of the issue. The "function that will open an alert dialog" that the instructions are asking you to use is simply the alert itself.