Programming in Swift: Fundamentals · Challenge: While Loops | raywenderlich.com


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/5539282-programming-in-swift-fundamentals/lessons/19

repeat {

print(“Counting down: (count)”)

count -= 1

} while count > 0

Why it is start counting down from 10 to 1?
When var value = 0

Ah - remember that the playground still has the code from the previous challenge there: so the first challenge counts up to ten…so when the first challenge loop is finished, count contains the value 10. So when the second challenge code executes, since I haven’t assigned any other value to count, the second loop simply starts off where the first loop ended off…and counts down from 10. Hope that helps!