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 trialTre Bu
1,521 PointsConfusion on the '[' + questions + ' questions left]'
Could someone explain why you have the apostrophes go where they are here?
Do the ' outside the brackets represent the whole string and the ' inside the brackets convert the 3 to a string and add spacing?
2 Answers
Steven Parker
231,268 PointsThe apostrophes (also known as "single quotes") enclose literal strings. The brackets are entirely inside the strings and have no meaning to the code. The syntax coloring provided by the formatter may help clarify this:
questionsLeft = '[' + questions + ' questions left]';
Note that the strings are a different color than the code. The system automatically coerces (converts) the number in "questions" into a string when it is combined with the other strings by the + operator.
Derek Ayres
2,607 PointsBLAMMO!!!!
Tre Bu
1,521 PointsTre Bu
1,521 PointsI understand now, thank you so much for the help!
Best
Steven Parker
231,268 PointsSteven Parker
231,268 PointsTre Bu — Glad to help. You can mark a question solved by choosing a "best answer".
And happy coding!