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

I answered, "Open an alert analog with the message "warning" with alert ("warning"); but still is saying i'm wrong. why?

jsrjh

index.html
<!DOCTYPE HTML>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JavaScript Basics</title>
</head>
alert("warning"); 
<script>
alert("Welcome back from treehouse);
<script>
alert("warning");
</html>

5 Answers

Andrew Rickards
Andrew Rickards
18,877 Points

The first alert is outside the script tag. And the second script tag isn't a closing one. You are also missing the closing quote on "Welcome back from treehouse" Try;

<!DOCTYPE HTML>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JavaScript Basics</title>
</head> 
<script>
alert("warning");
alert("Welcome back from treehouse");
alert("warning");
</script>
</html>

thank you for replying Andrew. My mistake the first question asked me to type "script src="scripts.js"></script> and got it right and 2nd question now is asking me to open an alert analog with the message "warning" but the hint says the code should be added to the code written in the previous task. I thought you can only have one file per script? I typed alert("warning"); on the next line below my first answer and still is wrong answer.

Andrew Rickards
Andrew Rickards
18,877 Points

Are you meant to put the alert in the script.js file instead of the HTML file?

It seems like it but then again I can't access any HTML file because its a challenge quiz. It just says to open an alert analog with the message but doesn't specifically tell me where to put it.

how can I show you screenshot of all my codes again? to show you what I changed?

Andrew Rickards
Andrew Rickards
18,877 Points

Which code challenge is it? I'll have a look.

Not certain which one exactly but its the first challenge for introduction to javascript. Stage 1 introducing javascript?

Andrew Rickards
Andrew Rickards
18,877 Points

The script tags need to go inside the body.

<!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>