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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Brahim Farhani](https://secure.gravatar.com/avatar/78ec4fc80cc07760226a967d62978bc5?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Brahim Farhani
1,534 PointsI do NOT UNDERSTAND THIS! HELP
Please help i dont no understand the term Condition and Loop, swell as while loop and do??????!??!?!?!
4 Answers
![Blair Rorani](https://uploads.teamtreehouse.com/production/profile-photos/39531/micro_kiwifruit-2018.jpg)
Blair Rorani
6,658 PointsA condition is another word for a 'state' that something or someone is in. For example, what is the condition of your stomach? Empty or full? (The condition of your house, the economy, your iPhone, etc).
If the condition of your stomach is empty, then you should eat something.
A loop is something that repeats (i.e. a cycle). So using the stomach example, you want to keep eating, until the condition of your stomach is full.
Condition and loop are just concepts we use to describe what we mean to a computer so it follows our instructions the way we intend.
Does that help?
![Stone Preston](https://secure.gravatar.com/avatar/c2b2872f48c222732218df9be85e1ed2?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Stone Preston
42,016 PointsLoops are used to execute some code over and over again.
while loops run some code while a certain condition is true. do while loops run an action at LEAST once, and then continue to loop if a certain condtion is true.
most loops have a condition, and a body. The condition is tested before each execution of the loop and if its true the loop executes, if its false the loop breaks from execution and does not loop again. Do while loops are an exception since the condition is tested after the loop runs, guaranteeing it will run at least once
you can use a while loop to do something as long as a condition is met
var score = 0
// the line below is the condition
while score < 10 {
// these lines inside the { } are the loop body
println("The score is less than 10)
score++
}
the above loop will continue to print out "the score is less than 10" for as long as the score is less than 10. since it starts at 0 and we increment it every time, the loop will stop running once the score hits 10.
a do while loop is used when you need the loop to run at least once.
// it will print at least one time, even if x is not equal to 10
do {
// this is the loop body
println(x)
// the line below is the condition
} while (x == 10)
the while loop is much more common than the do while loop in my experience. but even then you dont really use a while loop that much. the for in loop is probably the one that gets used most
![Brahim Farhani](https://secure.gravatar.com/avatar/78ec4fc80cc07760226a967d62978bc5?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Brahim Farhani
1,534 PointsCan u explain the ==
![codebully](https://uploads.teamtreehouse.com/production/profile-photos/1220972/micro_IMG_20140331_132940.jpg)
codebully
2,306 PointsSingle equal sign (=) is an assignment. for example, here is a constant; all dogs bark.
let dogsBark = true
Two equal signs (==) however evaluate a condition. Meaning if it's true that dogs bark, we will print a line that says so.
if dogsBark == true {
println("Dogs are barking.")
}
![beven nyamande](https://uploads.teamtreehouse.com/production/profile-photos/2190072/micro_beven.jpg)
beven nyamande
9,575 Points//== two equal signs means "is equal to"
// ie x==y means is x equal to y if its true it will return a boolean true and false otherwise
//example
var x = 10
var y = 20
if x==y {
// perform some function here
}
![Brahim Farhani](https://secure.gravatar.com/avatar/78ec4fc80cc07760226a967d62978bc5?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Brahim Farhani
1,534 PointsPlease this does no help is there anyway I can contact you for help, please :)
Brahim Farhani
1,534 PointsBrahim Farhani
1,534 PointsReally good Explanation !! Thank You Can you also explain the why he writes those lines of codes what to they mean the (<) and .count :)
Brahim Farhani
1,534 PointsBrahim Farhani
1,534 Pointslike the part where it says: println(todo[index]) index++ the index++ is what confuses me the most!!!!
Blair Rorani
6,658 PointsBlair Rorani
6,658 Pointsindex++ is a quick way of writing "increase the value of index by 1". index-- therefore means "decrease the value of index by 1"
.count is a property. An example of a property is "Blair.gender" which would return the value "male" because I'm a male. Other properties that a person might have are Blair.height or Brahim.favouriteFood etc.
.count is a property of an array (a group of items). If my array was called "seasons" and I used the count property like so "seasons.count" then it would return "4" winter, spring, summer, autumn.
I think the < you're referring to is less than. So if seasons.count (which we know is four) is < (less than) 4, then we know the year isn't finished yet (because there are 4 seasons in a year). Not sure if that example is helpful or not :)
Make sense?
Brahim Farhani
1,534 PointsBrahim Farhani
1,534 Pointsyes it does blair oh and blair are u good with swift?