Welcome to the Treehouse Community
Looking to learn something new?
Javier Hernandez1,822 Points
Confusion with the number string
Why do I need to place + on both sides on the inside of the "questions" variable like so: ... ' + questions + ' ... I would think that it would be: ... ' questions ' + ...
Jay Dacosta3,425 Points
I struggled with the writing of it at first too. It's because the  brackets make it feel like its part of the equation but really its just aesthetics as a string. The code would work the same if it was just:
var questionsLeft = questions + " questions left";
this would result in "3 questions left".
But he adds the  brackets to add to the look of the string and stand it out from the original text. He wants this:
[ 3 questions left ]
because of that you have to add the brackets as strings before the variable questions and on the end of the string hence the plus sign on both sides. Hope that helps
Steven Parker216,014 Points
The + sign is the concatenation operator, it tells the system that you want to join the contents of that variable to the strings on either side. You need one for each join, so one on each side.
You need to do that because you are joining (concatenating) 3 individual pieces of the final string you want to display.
- The first part is the string: " ["
- Then, you want to concatenate the number: + questions
- Finally, you will join the last part: + "] questions left."
After concatenating these 3 parts, you will get: "  questions left."