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

I'm confused?

its telling me to do println(), can somebody please help? if so, thanks :)

months.swift
let months = [1, 2, 3]
for month in months {
if month == 3{
println("January", "February", "March")

} else if month == 3 {

println ()

}

else {
println()
}


}

2 Answers

Stephen McMillan
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Stephen McMillan
iOS Development with Swift Techdegree Graduate 33,994 Points

It's asking you to print a month depending on what item it's currently iterating over in the loop.

Therefore: 1 = January, 2 = February and 3 = March.

So when you encounter a '1' you want print January:

  if month == 1 {
    println("January")
  } // Then here you would write an else if statement for the result of '2' and so on...

Hope it helped! :)

You also need to take the space out between the printl and the (). It should be println() not println (). Stephen is write. You have to put the string you want to print into the ().