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

Kavita Bargota
Kavita Bargota
2,741 Points

not complied??:(

It works in Xcode but not on here...please help

fizzBuzz.swift
  // Enter your code between the two comment markers

  for i in 1...100 {

    if (i % 3 == 0) && (i % 5 == 0) {
    print("FizzBuzz")
} else if (i % 3 == 0) {
    print("Fizz")
} else if (i % 5 == 0) {
    print ("buzz")
} else {
    print (i)
}



  // End code

}

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,858 Points

Hi Kavita,

This challenge has very specific instructions that you are not following.

The code will work on your local machine, but there are many things that are not satisfying the instructions:
For example, the instructions say to use return but you are using print... The instruction say to not include a range of values, but you do... plus a couple more things.

Syntactically and logically, you're code looks great!! :thumbsup:
But, have a careful look at the instructions again and refactor your code to match them exactly, then the challenge will pass.

Keep Coding! :) :dizzy: