JavaScript JavaScript Basics (Retired) Introducing JavaScript Write Another Program

Fidel Zv
Fidel Zv
1,625 Points

I don't know how I am supposed to add an opening and closing script tag inside the body of the page. I'm a bit confused

This is what I did and it keeps telling me syntax error but have no clue how to fix it

index.html
<!DOCTYPE HTML>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JavaScript Basics</title>
  <script>
  alert("Here's another message from Treehouse");
  <script>
</head>
<body>
  <div class="container">
  <h1>where to place your Javascript code.</h1>
  </div>
  <script src="scripts.js"></script>
</body>
</html>

3 Answers

Hey Fidel,

You are going to want to put your <script> tags inside of the <body> tags make sure the closing </script> tag is within the nest of the closing </body> tag. For this challenge you are doing inline scripting and don't need a link to your external javascript page.

It would look like this.

<!DOCTYPE HTML>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JavaScript Basics</title>
</head>
<body>
  <h1>where to place your Javascript code.</h1>
  <script>
      alert("Warning!");
  </script>
</body>
</html>

Between <body> and </body>

<script> alert('Warning!'); </script>

Fidel Zv
Fidel Zv
1,625 Points

Thanks a lot Dylan