Welcome to the Treehouse Community
Looking to learn something new?
Seth EllisCourses Plus Student 5,950 Points
I don't comprehend the syntax ' [ ' + questions + '] and how that produced the number 3 from var questions = 3
I don't comprehend the syntax ' [ ' + questions + '...] and how that produce the number 3 from var questions = 3 to be utilized in the math.
Greg Kaleka39,019 Points
'[' + questions + '...]'
turns into "[3...]". Don't let the square brackets throw you off! They're just text in this case.
Here's how you might use it if you were coding a game that reported the users score:
var score = 10000; alert('Good job! You scored ' + score + ' points!!!');
This would display an alert with the text "Good job! You scored 1000 points!!!"
By these lines in the beginning of your code
var questions = 3;
you are adding the value 3 to your here defined variable questions. The value of questions is now 3 for the following usage of the variable questions.
' [ ' + questions + '...] '
Hope this clearifies it for you :)
Jim McQuarrie10,597 Points
I had the same issue and had to play with it to get it, would have been a lot easier understanding without the square brackets throwing me off. So I wrote it like this:
var questions = 3; var questionsLeft = '. There are ' + questions + ' questions left'; var adjective = prompt('Please type an adjective' + questionsLeft); questions -= 1;
Hope this helps, Jim