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

Rodi Haas
Rodi Haas
1,504 Points

i don't get it?

it is inside of it

index.html
<!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>

2 Answers

Greg Kaleka
Greg Kaleka
39,021 Points

Hi Rodi,

Just drop the double quotes, and you'll be fine. Should look like this:

index.html
<!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>
Rodi Haas
Rodi Haas
1,504 Points

oke thank you :D.

but why??

Greg Kaleka
Greg Kaleka
39,021 Points

Hey Rodi,

If you put double quotes around the single quotes, the alert will itself have single quotes around it, like this:

screenshot

If you use just single quotes (or just double quotes, for that matter), the alert will look like this:

screenshot

It's a question of style, but I would definitely want the second version, and in the case of the challenge, that's what they were looking for. I understand why it's a bit ambiguous, though, since they tell you to show an alert with 'Warning' in it... not clear if they just want the word, or if they actually wanted the quote marks in the alert itself. Turns out they just want the word :).

You're really close! Just use the single quotes and not the double quotes and you should be good to go!

alert('Warning!');

this is what they are asking for. I hope this helps.

In JavaScript, you can use either single or double quotes. In this challenge they are asking you to use single quotes.