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

James George
James George
476 Points

Inside the script tags, write a function that will open an alert dialog with the message 'Warning!'

I do not know what to write and where to place the function

index.html
<!DOCTYPE HTML>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JavaScript Basics</title>
</head>
<body>
</body>
  <script src="scripts.js">
  </script>
    function thealert() 
    {
      alert('Warning');
    }
    alert();
</html>
<script>

2 Answers

Phillip Kerman
PLUS
Phillip Kerman
Courses Plus Student 285 Points

Move the "closing" script tag:

 </script>

Below your code (after the last bit of code) so that your code is between <script...> and </script>

Note, too, the following code can be removed, or more likely changed to say "thealert()":

alert();
Tolga Durukan
Tolga Durukan
12,614 Points

If you look at the bottom part of your code you will see you have placed your codes not inside of the body tags nad your closing script tag outside of html tag so you should put the script tags at the end of your body tag. like this :

<body> <script>

function theAlert() {

alert('Warning'); }

theAlert();

</script> </body>