Programming in Swift: Fundamentals, Episode 21: Challenge: For Loops | raywenderlich.com

Practice using for loops on your own, through a hands-on challenge.


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

Challenge 2 in this episode seems to have two mistakes in the playground file:

  • „rangestart + 3“ (not „…S…“?)
  • „Print out „Range value is X“, where C is the value of rangeStart (not „…Value“?)
1 Like

I found this too…

The instructions read:
Challenge 2

Create a for loop that prints out a range of three numbers, the starting point of which you can control with a constant.

Declare a constant named rangeStart and set it to 10.

Use rangeValue as your loop value.

Your for loop range should be from rangeStart to rangestart + 3, but it should be a half-open range.

Print out “Range value is X”, where X is the value of rangeStart.

When you have your loop working, change the rangeStart constant to a different number to create a different range.

but the answer Is (note the differences in bold):
`
let rangeStart = 10

for rangeValue in rangeStart…<rangeStart + 3 {

print(“Range value is (rangeValue)”)

}
`