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

peterson st gourdain
peterson st gourdain
931 Points

how to add a warning in a script

how to add an alert

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>
</body>
<script>
alert("warning.");
</script>
</html>

2 Answers

A line of code needs to be called upon to be executed, in this case, you need to create a function, then call the function to run it. Example:

// this is the function
function theAlert() {
      alert("Warning!");  // this is the message
    }
    theAlert(); // and here is the function call

Hope this helps, cheers.

Steven Parker
Steven Parker
231,269 Points

:warning: Creating and calling a function is not part of this challenge.

Steven Parker
Steven Parker
231,269 Points

Your alert call is correct, but you have some other issues:

  • the code has an extra set of script tags with a src attribute that are not part of this challenge
  • both script tags with the code in between should be inside the body element

There's no need to create an extra function for this challenge.

peterson st gourdain
peterson st gourdain
931 Points

still not working i dont understand whats wrong

Steven Parker
Steven Parker
231,269 Points

Both issues must be fixed for it to work.