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

you printed [January, Febuary, March] and we were looking for [January, Febuary, March]

I dunno I did wrong

months.swift
let months = [1, 2, 3]

for month in months {
  if month == 1{
    println("January")
  } 
  else if month == 2 {
    println("Febuary")
  } 
  else if month == 3 {
    println("March")
  }
}

6 Answers

Thomas,

Everything looks good, except you misspelled February. You are missing the first R. I believe I did the same thing when I did this Challenge!

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")
  }
}

Regards,

Florin

Anish Walawalkar
Anish Walawalkar
8,534 Points

typo:

Febuary should become February

ah lol

how come I got this Swift

0 swift 0x00000001113e5edb llvm::sys::PrintStackTrac e(sFILE*) + 43 1 swift 0x00000001113e661b SignalHandler(int) + 379 2 libsystem_platform.dylib 0x00007fff87a21eaa _sigtramp + 26 3 libsystem_malloc.dylib 0x00007fff8c2dfc6f tiny_malloc_from_free_lis t + 1443 4 swift 0x000000010f9610bf llvm::MCJIT::runFunction( llvm::Function*, std::1::vector<llvm::GenericValue, std::__1::allocato r<llvm::GenericValue> > const&) + 271 5 swift 0x000000010f9637f6 llvm::ExecutionEngine::ru nFunctionAsMain(llvm::Function*, std::1::vector<std::1::basic_string <char, std::__1::char_traits<char>, std::1::allocator<char> >, std:: 1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, s td::1::allocator<char> > > > const&, char const* const*) + 1190 6 swift 0x000000010f7fd33c swift::RunImmediately(swi ft::CompilerInstance&, std::1::vector<std::__1::basic_string<char, std ::__1::char_traits<char>, std::1::allocator<char> >, std::1::allocat or<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::a llocator<char> > > > const&, swift::IRGenOptions&, swift::SILOptions con st&) + 2044 7 swift 0x000000010f4f6694 performCompile(swift::Com pilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&) + 13428 8 swift 0x000000010f4f300a frontend_main(llvm::Array Ref<char const*>, char const*, void*) + 2682 9 swift 0x000000010f4ef697 main + 2247 10 libdyld.dylib 0x00007fff883e35ad start + 1 Stack dump:

  1. Program arguments: /Applications/Xcode-beta.app/Contents/Developer /Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -interpret tmp/BN4SBjo4si.m -target x86_64-apple-darwin15.2.0 -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.pl atform/Developer/SDKs/MacOSX10.11.sdk -module-name BN4SBjo4si

from this

var boo = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
let increment = 0
var n=0
for var increment = 0; increment < boo.count; increment++ {
    switch boo[increment]%n{
        case 3:
            print("fizz")
        case 5:
            print("buzz")
        default:
            print("hihoe")
    }
}

Thomas,

Is this for the same the same challenge? Can you copy and paste the URL for where you put the code in?

Florin

Thomas,

I think this is caused by the %n at the end of the switch line.

Did you mean this instead?

var boo = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
let increment = 0
var n=0
for var increment = 0; increment < boo.count; increment++ {
    switch boo[increment] {
        case 3:
            print("fizz")
        case 5:
            print("buzz")
        default:
            print("hihoe")
    }
}

Florin