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

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

Boris Davidovic
Boris Davidovic
1,010 Points


can someone tell me what am i doing wrong here ?

thanks !

Steve Hunter

bool hasBonus;
  int powerPoints = 5;

if (powerPoints < 3) {
  hasBonus = FALSE;

else {
  powerPoints >=3
  hasBonus = TRUE;


2 Answers

Hi Boris,

You've correctly created an if statement. This tests one condition and executes a command if that condition is true else it executes another command. The if/else construct is a binary thing. It tests one condition. A true result goes one way, the other way is the false result; it is the mutually exclusive opposite of the condition tested.

So, you've tested in your if statement condition if(powerPoints < 3) ). If that's false, you set hasBonus to FALSE or NO or whatever. Then, you enter the else clause. You don't retest the condition, the result is already set - the only other option is TRUE. You have already established that powerPoints is less than three - so what benefit is there in testing if it is >= 3? You already know it isn't if you've reached the else clause.

I hope that makes sense; let me know if it doesn't.

In the interests of keeping code brief, which isn't what this challenge is about, how about assigning the value of your condition to hasBonus? Would this work?

hasBonus = powerPoints >= 3;

The expression to the right of the equals evaluates to TRUE or FALSE there are no other options; it is either less than 3 or not. So, why use the if conditional statement at all? This won't pass this particular challenge because it is specifically looking for an if statement, but consider this as a viable real-world solution.

I hope that helps,


Boris Davidovic
Boris Davidovic
1,010 Points

Thanks my man Steve :)

hope other people benefit from your detailed answer.

Cheers !


Boris Davidovic
Boris Davidovic
1,010 Points

i solved the problem with removing the powerPoint >=3; can someone explain please why is this one too much and not relevant ?

thanks !