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) Storing and Tracking Information with Variables Review Strings, Numbers and Spaces

Lesson "strings, numbers and spaces" Quiz 1 of 5. None of the answers account for the quote in you're??

The question on the quiz is: Which of the following creates the variable message and stores a string value in it? var message = “These are not the droids you’re looking for"

It looks to me that the only correct answer to this question will produce a nonsensical string : 're looking for'. Because this has 2 single quotes enclosing some letters. Wouldn't the computer accept this as a correct string even tho a human would say this is nonsense?

4 Answers

Ted is correct. when using quotes in strings you need to know that once you start with either ("") or ('') single or double quotes you need to use the opposite in the string in order for the string to include all the information you want. if you want here is a short list of quotes in JS.

http://www.w3schools.com/js/js_strings.asp

Thanks!

Not a problem. that's what we are here for!

Jeff Lemay
Jeff Lemay
14,268 Points

The single quote in "you're" will not affect your string since you wrapped it in double quotes. But, if you wrap strings in single quotes that would cause a problem.

Thanks!

geoffrey
geoffrey
28,736 Points

The answer is correct, single quotes are allowed inside a string surrounded by double quotes.

Some valids strings

var message1 = "These are not the droids you're looking for"; // the right answer in the quizz
var message2 = 'These are not the droids you\’re looking for';
var message3 = "He told me:\"you should go away\"";
var message4 = 'He told me:"You should go away"';

You can test it inside the console, there are no errors.

You can force the character with a \ or you can look up the code that means single quote.