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

Raymond Espinoza
Raymond Espinoza
1,989 Points


cant seem to solve this code .

func fizzBuzz(n: Int) -> String {
  // Enter your code between the two comment markers
  var n = 3 "buzz"
  // End code
  return "\(n)"

1 Answer

Honestly, you might want to go back to some of the previous videos to brush up on your basics.

Some ideas where to start...

  1. Read up on your operators. In this case, specifically the equivalence operator (==) and the logical "AND" operator (&&). Using the = sign will declare a variable, not check for equivalence)
  2. How to print statements ( you're missing "print" and it should be on a second line)
  3. You're not checking for Fizz, or FizzBuzz. You have to check n against all three possibilities.
  4. How to use the "remainder" operator (%)
  5. If it says put code between the two comment markers ("//"), I would suggest following those instructions as the compiler might not read it correctly.