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

Bummer! Better check your syntax

That would be the iOS Development with Objective-C (Objective-C Basics)

Review Scope and Loops

it asks to :

Create an int called mathTotal. Also, create a bool called 'isComplete'.

and

Create a for loop that will begin with a value of 5 and end with a value of 25. In each iteration, add the incrementing value to mathTotal. When the loop has finished running, set 'isComplete' to true. (HINT: the last value used INSIDE the loop should be 25)

int mathTotal;
BOOL isComplete;

for (mathTotal = 5; mathTotal <= 25; mathTotal++) {

}

isComplete = TRUE;

OR I could do this

int mathTotal;
BOOL isComplete;

for (mathTotal = 5; mathTotal <= 25; mathTotal++) {

if (mathTotal == 25) {

isComplete = TRUE;

}


else {

isComplete = FALSE;

}


}

I'm really confused right now about the loop subject.

the initialization always need to have an i ? like this:

 int i = 5; 

Why can't I use the mathTotal? instead I always have to use i?

so it would be like that:

int mathTotal;
BOOL isComplete;

for ( int i = 5; i <= 25; i++) {

mathTotal += i;

}

isComplete = TRUE;

So confused! I review the videos already but still don't know why I can't use my integer called mathTotal.

if someone could help me understand this would be wonderful! Thank you very much for your time.

The answer in the link below might be helpful:)

https://teamtreehouse.com/community/please-help-what-am-i-doing-wrong