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 Collections and Control Flow Control Flow With Conditional Statements FizzBuzz Challenge

Says "Bummer double check work for Fuzz values and make sure you are returning the correct string."

I've double checked the values and everything is correct from what I can see.

fizzBuzz.swift
func fizzBuzz(n: Int) -> String {
  // Enter your code between the two comment markers
  //Divisible by 6: "Fizz", divisible by 5: "Buzz", divisible by 15: "FizzBuzz", Default: orig number (n)
    switch n {
    case let n where n % 6 == 0:
    return "Fizz"
    case let n where n % 5 == 0:
    return "Buzz"
    case let n where n % 15 == 0:
        return "FizzBuzz"
    default:
        return "\(n)"
}
  // End code
  return "\(n)"
}

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,858 Points

Hi Andrew,

The values you seem to be using do not match what the instructions are asking for. Challenges are very specific and the instructions always need to be followed explicitly.

The video prior clearly states that:
"Fizz" needs to be divisible by 3
"Buzz needs to be divisible by 5
"FizzBuzz" needs to be divisible by both 3 AND 5

This challenge is even more specific then most others, even one little deviation from the instruction and the code will not pass. Remember, just because it works on your machine does not mean that it will pass the challenges.

I also see that you have a default case, which the instructions specifically state not to include.

I suggest starting a fresh challenge and make sure the instructions are followed exactly.

Keep Coding! :dizzy: :)