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 trialmonica shim
2,197 PointsMadLibs Challenge Syntax Explanation - Use of quotes and plus sign
Why does + sign go in between the quotes in below? var questionsLeft = ' [ ' + questions + ' questions left] ' ;
Could someone interpret this syntax step by step?
1 Answer
Patrick Hager
15,539 PointsAlthough I haven't done the JS courses yet, I'd assume the reason it's set up this way is that the variable questionsLeft is assigned the opening square bracket "[" then the contents of the variable questions (+ questions) and finally assigned the string questions left] (+ "questions left]". That way when you call the variable questionsLeft later it will spit out to the screen something like "[5 questions left]".
I hope that cleared things up a little bit.