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 trialHans Lohmann
414 PointsI'm stuck on a for_in loop, and an if statement, I have a screenshot for anyone to take a quick look and give me an opin
Hans Lohmann
414 Points@William Li I cut the the web address from the tool bar at the top the page and pasted it below, is this correct to send you a link? https://teamtreehouse.com/library/swift-basics/control-flow/if-statement-2
2 Answers
William Li
Courses Plus Student 26,868 PointsOn line 3 of your code, you didn't use if
statement, that you should.
Here's the correct version, properly indented.
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")
}
}
Hans Lohmann
414 Points@ WilliamLI Oh my gosh that was all. I have been trying to learn code as soon as I can so I spend a lot of time studying (today I have been working since midnight and its now dawn here). After a lot of time studying sometimes I miss little things like that, which makes your code not work. Thank You.
William Li
Courses Plus Student 26,868 PointsNo problem, Hans. Also I would like to point out one thing here.
The best way to post a question you have with a code challenge to the forum, is to do it from within the Code Challenge's page.
Click the Ask A Question button and you'll be able to post question to the forum. Now, there're 2 big advantages here.
- the link to the original code challenge will be embedded to the forum post, this way people won't be confused on which question you're referring to; and you don't have to copy/paste the link.
- whatever code you've currently written on the Code Challenge will be embedded to the post as well, that saved you the trouble of snapping a screenshot and upload the pic. Pretty neat, right?
Hope this helps you make the most out of the forum, cheers.
Hans Lohmann
414 Pointsok that sounds good. I was working on Objective C in the meantime, while I was waiting for help on this question. I may need to try that in a few minutes. Cool
William Li
Courses Plus Student 26,868 PointsWilliam Li
Courses Plus Student 26,868 PointsHans, can you provide link to the code challenge?