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

Ashlee Sharp
PLUS
Ashlee Sharp
Courses Plus Student 1,694 Points

I'm really not sure what I'm not understanding.

I am trying to write a function that will open an alert dialog with the message 'Warning!' inside the script tags, but I don't know what I am getting wrong. It keeps saying that task 1 is not longer passing, after I try to write the code like this.

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

Eric Ayres
Eric Ayres
4,233 Points

Ashlee your alert is fine. all you have to do is eliminate the <script src="scripts.js"></script> line. you're trying to reference something that doesn't exist. Your on the right path your just getting a little ahead of yourself. As you can see you can't tab over to that scripts.js from the index,.html cause it hasn't been created just yet.

Ashlee Sharp
Ashlee Sharp
Courses Plus Student 1,694 Points

I understand completely now, duh, thank you so much for your help!

Trevor Johnson
Trevor Johnson
14,427 Points

You are linking to a separate js file, and then creating an <script> tag within that. You don't need to do that. You can write the function in your HTML file, or you can write it in scripts.js and link to it.

Ashlee Sharp
Ashlee Sharp
Courses Plus Student 1,694 Points

Oooh! I got it now, thank you so much for your help!