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 trialIdriss Kone
Courses Plus Student 510 PointsControl Flow stage 5, If statement exercise. Need help
it keeps saying my code is incorrect, can anyone show me the code? my code : for i in months{ if i == 1{ println("January") } else if i == 2{ println("Febuary") } else if i == 3 { println("March") } else { println(i) } }
1 Answer
Jason Lysinger
1,365 PointsThis challenge was just looking for an for-in and if statements. Not the else if.
So this is what they were looking for:
for month in months {
if month == 1 {
println("January")
}
if month == 2 {
println("February")
}
if month == 3 {
println("March")
}
}