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 trialjurgen meco
30 Pointsim stuck
please help
let numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
while numbers
1 Answer
Jhoan Arango
14,575 PointsHello Jurgen:
βA while loop performs a set of statements until a condition becomes falseβ Excerpt From: Apple Inc. βThe Swift Programming Language.β iBooks. https://itun.es/us/jEUH0.l
let numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] // the array of numbers
var index = 0 // A variable with a value of 0
while index < numbers.count { // This condition is true
println(numbers[index]) // We print the values each time the loop passes by
index++ // we add one value each time the loop passes until is about 10
}
/*
So while index is below 10, the loop will print out each number, and since
index is being added ONE value each time the loop passes, index will
become higher than 10 and it will make the condition false, and
the loop dies.
*/
hope you understand , if need any more clarification please let me know.
jurgen meco
30 Pointsok, thank you very much :D
Jhoan Arango
14,575 PointsJhoan Arango
14,575 PointsLet me work on your answer ! give me a few mins.. :)