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

Savannah Walters
Savannah Walters
401 Points

Do I have to add, <script src+"script.js"<>/script> before my alert in the body? Why is it telling me it is wrong?

The computer is saying my formula is incorrect? can you shed some light on what I am doing wrong?

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>

Theres nothing wrong with putting the <script src="scripts.js"></script> in the body tag (But I would recommend putting it just above the closing body tag </body>. Your problem is you are trying to code javascript in html. The alert function is to be written in a js file

3 Answers

andren
andren
28,558 Points

This challenge does not want you to add more than one <script> tag. And it does not want you to link to an external script file, it just wants you to add the alert code within the <script> tag.

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>

Just remove the first script tags (<script src=""></script>) that's causing the error. In the excercise you just have to show an alert.

Savannah Walters
Savannah Walters
401 Points

Thanks so much for your help!!