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

I got creative with an answer, and don't know why it's not working

I was told to assign an "if" value to a for-in statement that made the set:

let months = [1,2,3]

become January, February and March.

My original solution was the one they wanted and was correct:

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

But then I wanted to try a creative one and wrote:

let months = [1, 2, 3] var February = 1 for month in months {if month<2 {println("January")} else if month=February {println("February")} else if month>2 {println("March")} }

And it said it was incorrect.

Any thoughts?

1 Answer

Figured it out: var February = months [1] as opposed to var February = 1.