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

How do I 'call alert' I am a little confused about this part

Hi Im having a hard time understanding what they mean when they say I did not call alert. Thank you!!

index.html
<!DOCTYPE HTML>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JavaScript Basics</title>
</head>
<body>
<script>
  document.write("Warning!");
  </script>
  document.write("Warning!");
</body>
</html>

2 Answers

Steven Parker
Steven Parker
231,269 Points

When you "call" a function, you put the function's name followed by a pair of parentheses. If the function requires any arguments (as this one does), they go inside those parentheses. The code here is calling "document.write" instead of "alert".

Also, you only need to write your code one time, and only between the "script" tags.

I have removed the unnecessary second line. It now looks like this. where am I going wrong? What am I missing? <script> document.write("Warning!"); </script>

NVM, I got it. Thank you. Except I didn't have to write document.write. Just alert

<!DOCTYPE HTML>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JavaScript Basics</title>
</head>
<body>
  <script>alert('Warning!')</script>
</body>
</html>