Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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 ().