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 trialMartin Scott
1,755 PointsLesson "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
Jacob Mishkin
23,118 PointsTed 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.
Jeff Lemay
14,268 PointsThe 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.
Martin Scott
1,755 PointsThanks!
Jeff Lemay
14,268 PointsYou're welcome!
geoffrey
28,736 PointsThe 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.
Ted Sumner
Courses Plus Student 17,967 PointsYou can force the character with a \ or you can look up the code that means single quote.
Martin Scott
1,755 PointsMartin Scott
1,755 PointsThanks!
Jacob Mishkin
23,118 PointsJacob Mishkin
23,118 PointsNot a problem. that's what we are here for!