Welcome to the Treehouse Community
Looking to learn something new?
Jonathan Franklin3,883 Points
Question about using var
Yes, it does think you are trying to create a new variable. Adding 'var' to the beginning is declaring a new variable. When your referencing the variable to modify etc you don't include the 'var'.
It is thinking exactly that. By saying
var questions = 3;
you're declaring a variable, whereas by ommiting "var" and saying
questions -= 1;
you're assigning it a new value. You need to declare "questions" before doing so though, otherwise you'll end up with a Reference Error.
"var questions -= 1" wont work and will result in a Syntax Error.
It doesn't think you are creating a new variable, you are creating a new variable. The
var keyword is used to declare variables, declare in this context being a fancy word for create. When you are just referencing an existing variable either to get or change its value you are not meant to include the
Edit: Oops seems I was a bit late to the party