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 trial

JavaScript

JavaScript how does this argument if(this.getCurrentQuestion().isCorrectAnswer(answer);) evaluate to a boolean

 if(this.getCurrentQuestion().isCorrectAnswer(answer);){   ///dont both have to return a boolean for the argument to be true
     this.score++;
      }
Quiz.prototype.getCurrentQuestion = function() { //// how does this return true or false
  return this.questions[this.currentQuestionIndex];

};

Question.prototype.isCorrectAnswer = function(choice){ // i DO understand that is returns a Boolean 
    return this.answer === choice;
};

// im NOT GETTING ERRORS I JUST DONT UNDERSTAND HELP PLEASE 
// MAYBE ANOTHER SIMPLER EXAMPLE

1 Answer

I am pretty sure anytime you use a conditional you are writing a boolean statement. if... true or false.

With your quiz.prototype... I'm not exactly sure other than the fact that 0 can be interpreted as false and any other value that isn't zero or empty can be interpreted as true. I hope this helps.