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 Cornwell
PLUS
James Cornwell
Courses Plus Student 92 Points

How do I put alert("Warning!"); into a direct function like stated in the instruction video?

I need a better explanation of how to add the alert into a function for this second challenge. I have watched the video 3 times and get confused during this portion.

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!");



</body>
</html>

1 Answer

Steven Parker
Steven Parker
229,708 Points

Your JavaScript code should be between a starting <script> tag and an ending </script> tag, but the ending tag seems to be missing.

Also, there should be only one set of script tags in this challenge. And the instructions don't ask for it to have a "src" attribute. That's only used when you want to pull in a script from an external file.