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 trialAli Sutcu
Courses Plus Student 1,243 PointsCan i do it with switch statement ?
I already completed this challenge but i also tried to do it with switch statement but i am getting tons of errors. is this challenge can be done with switch? If it is please help me with this...
2 Answers
Steven Deutsch
21,046 PointsHey Ali Sutcu,
I answered this question in a previous post. Check it out here:
https://teamtreehouse.com/community/not-sure-which-part-of-my-code-is-incorrect
Good Luck
Ali Sutcu
Courses Plus Student 1,243 PointsI get error on both of them. Here is my code :
func fizzBuzz(n: Int) -> String {
// Enter your code between the two comment markers
switch n {
case n % 3 == 0: return "Fizz"
case n % 5 == 0: return "Buzz"
case n % 3 == 0 && n % 5 == 0: return "FizzBuzz"
default: return "\(n)"
}
return "\(n)"
}
Josh Minor
2,947 PointsJosh Minor
2,947 PointsIts possible, are you getting errors in playground or just the treehouse compiler?