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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![NATHAN TRAN](https://secure.gravatar.com/avatar/4ce84a23395fe39de7418e5750e8bbcd?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
NATHAN TRAN
2,367 PointsWhat am I doing wrong?
What am I doing wrong? Where is my error? My compiler is right on xCode.
func fizzBuzz(n: Int) -> String {
// 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
return "\(n)"
}
3 Answers
![Jason Anders](https://uploads.teamtreehouse.com/production/profile-photos/3512822/micro_Jason_s-Pic.jpg)
Jason Anders
Treehouse Moderator 145,859 PointsHey Nathan,
While your code is correct and will run in Xcode, you didn't follow any of the very specific instructions the challenge has given, and this is why you are receiving the Bummer!
- "The challenge also does not need you to loop over a range of values (using for or while). I'll take care of that." -- So, you need to remove the for loop.
-
"Change your variable/constant name that you are checking in each step to n." -- You will need to change all the variables you named
i
back ton
. - "Change all your print statements to return statements. For example: print("FizzBuzz") becomes return "FizzBuzz"." -- self-explanatory.
-
"Do not worry about the default case" -- You'll need to delete the final
else
clause.
Challenges are very specific and extremely picky, so you'll always need to follow the instructions exactly. Once you fix up your code to satisfy the instructions, you're all good to go. :)
Keep Coding!
![NATHAN TRAN](https://secure.gravatar.com/avatar/4ce84a23395fe39de7418e5750e8bbcd?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
NATHAN TRAN
2,367 PointsI did this:
if (n % 3 == 0) && (n % 5 == 0) { print("FizzBuzz") } else if (n % 3 == 0) { print("Fizz") } else if (n % 5 == 0) { print("Buzz") }
They program still tells me that it is wrong:
"Bummer! Double check your logic for Fizz values and make sure you're returning the correct string!"
What is wrong with my "Fizz" value?
![Jason Anders](https://uploads.teamtreehouse.com/production/profile-photos/3512822/micro_Jason_s-Pic.jpg)
Jason Anders
Treehouse Moderator 145,859 PointsYou're still using print
when the challenge explicitly says to use return
.
![NATHAN TRAN](https://secure.gravatar.com/avatar/4ce84a23395fe39de7418e5750e8bbcd?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
NATHAN TRAN
2,367 PointsGot it! Thanks Jason!!