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 trialRodi Haas
1,504 Pointsi don't get it?
it is inside of it
<!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
39,021 PointsHi Rodi,
Just drop the double quotes, and you'll be fine. Should look like this:
<!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>
Jacob Mishkin
23,118 PointsYou'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.
Rodi Haas
1,504 PointsRodi Haas
1,504 Pointsoke thank you :D.
but why??
Greg Kaleka
39,021 PointsGreg Kaleka
39,021 PointsHey Rodi,
If you put double quotes around the single quotes, the alert will itself have single quotes around it, like this:
If you use just single quotes (or just double quotes, for that matter), the alert will look like this:
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 :).