Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Objective-C Basics Introduction to Operators and Conditionals Review IF / ELSE

Arjun Parashar
PLUS
Arjun Parashar
Courses Plus Student 2,150 Points

I'm not able to figure out this question.

Please help me with the answer to this question.

variable_assignment.mm
bool hasBonus;
int powerPoints =3;
if ( hasBonus >= powerPoints ) {
  hasBonus = false;
}
else { hasBonus = true;
     }

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,631 Points

Hey Arjun,

While the syntax of you code is correct, I feel you may have misread the instructions for the second task.

First, you didn't assign the correct value to powerPoints... you gave it 3, but the task specifically asks for it to be assigned 5.

Second, you are comparing hasBonus to powerPoints in the conditional, but the tasks asks explicitly for you to compare powerPoints to a hard-coded value of 3.

With this in mind, go back and give it another shot. Pay close attention to the instructions. Challenges are very picky and will only pass if you do exactly what is asked.

Keep Coding! :) :dizzy:

Arjun Parashar
Arjun Parashar
Courses Plus Student 2,150 Points

Thank you for your reply. I was able to solve it. :)