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

Chris Mitchell
Chris Mitchell
3,011 Points

whats wrong ?

whats wrong with my code

index.html
<!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>
  <script src="scripts.js"></script> 
</body>
</html>

2 Answers

Raffael Dettling
Raffael Dettling
32,999 Points

You don´t need the second script only use the warning script and you´re fine :)

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

To be honest, when I started composing my answer, yours still wasn't visible on this post. You were succinct in your response and quick to respond. Thank you for helping out in the Community and here's un upvote from me! :sparkles:

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! I'm not sure that I'd say that there's anything really wrong with your code other than it doesn't exactly match what the challenge asks you to do. Rather, you did what the challenge asks, but then you did something extra. You are linking to an external JavaScript file which is not asked for by the challenge. Chances are that this file doesn't exist in this context and that is what is causing the error.

If I simply delete this line, your code passes:

 <script src="scripts.js"></script>

On a side note, while it's not absolutely necessary in this case, it's generally considered best practice to end all statements with a semicolon, so I would get used to writing your correct line this way:

alert("Warning!");

:bulb: Going forward, it's important to note that you should avoid doing anything that is not explicitly asked for by the challenge. Even if functional outside the challenge, it can cause the challenge to fail. These are very strict and looking for specific results.

Hope this helps! :sparkles:

Raffael Dettling
Raffael Dettling
32,999 Points

Maybe i should put more effort in my answers:) Have an upvote.