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 trialpeterson st gourdain
931 Pointshow to add a warning in a script
how to add an alert
<!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
Martin Zarate
10,723 PointsA 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
231,269 PointsYour 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
931 Pointsstill not working i dont understand whats wrong
Steven Parker
231,269 PointsBoth issues must be fixed for it to work.
Steven Parker
231,269 PointsSteven Parker
231,269 PointsCreating and calling a function is not part of this challenge.