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 Swift Basics (retired) Control Flow If Statement

viviana mendoza
viviana mendoza
2,967 Points

How is the month value assigned?

I see how the (months)plural version is equivalent/assigned to the array months [1,2,3] but i don't get how singular (month) is connected/ gives the results

Jeremy Hayden
Jeremy Hayden
1,740 Points

Viviana, It would be helpful if you post the code or the quiz question that your having trouble with.

1 Answer

Kieran Robinson
Kieran Robinson
9,411 Points

The code challenge you've linked to needs you to create a 'for-in' loop to go through the array [1,2,3] and when it gets to number 1 in the array, you need to print "January", when it gets to number 2, print "February" and finally when number 3 is reached, print "March"

let months = [1, 2, 3]

for month in months { if month == months[0] { println("January") } else if month == months[1] { println("February") } else if month == months[2] { println("March") } }