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 trialBrennan Altringer
7,660 PointsIf statement code challenge for swift. I feel like this is the answer but it isn't accepting it. Can someone help me?
Nothing is writing to the console in the online compilers I am using. Seems weird?
1 Answer
Michael Reining
10,101 PointsThis worked for me
let months = [1, 2, 3]
for month in months {
if month == 1 {
println("January")
} else if month == 2 {
println("February")
} else if month == 3 {
println("March")
}
}
NOTE: In Swift 2.0, you have to change println to print
PS: Thanks to the awesome resources on Team Treehouse, I just launched my first app. :-)
Brennan Altringer
7,660 PointsBrennan Altringer
7,660 Pointsif anyone runs into this problem they were looking for this:
let months = [1,2,3]
for index in months { if index == 1 { println("January") } else if index == 2 { println("February") } else if index == 3 { println("March") } else { println("Other") } }