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

Sean Lafferty
Sean Lafferty
3,029 Points

Again, cant understand

Had another go but still no luck

fizzBuzz.swift
func fizzBuzz(dude: Int) -> String {
  // Enter your code between the two comment markers

  if (dude%<=0) {
    print("fizz")
  }

  else (dude%<=0) {
    print("buzz")
  }

  else if (dude%3+5<=0) {
    print("FizzBuzz"
  }

  // End code
  return "\(dude)"
}

Hi again Sean,

I have just replied to your previous question which should help.

It appears that you are trying to use a function again which Treehouse implies to do, however this is just so they can convert your solution into a function to check that it is correct

If you use a for in loop, and an if statement to complete the challenge in Xcode (which I recommend is where you complete all code challenges) and then copy and paste it over to Treehouse and follow their conversion instructions specifically, I think you will be better of.

Good Luck!

Mitch

1 Answer

func fizzBuzz(dude: Int) -> String {
  // Enter your code between the two comment markers
if (dude % 15 == 0) {
    return "FizzBuzz"
  }else if (dude % 3 == 0) {
    return "fizz"
  }else if (dude % 5 == 0) {
    return "buzz"
  }
return "\(dude)"