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 trialJay Siddik
11,901 Pointshere is it ..... Help!!!!
Jennifer Nordell explain me this ....
func fizzBuzz(n: Int) -> String {
// Enter your code between the two comment markers
func fizzbuzz(n: Int) -> String {
switch (n % 3 == 0, n % 5 == 0) {
case (true, false): print("Fizz")
case (false, true): print("Buzz")
case (true, true): print("FizzBuzz")
default: return String(n)
}
}
// End code
return "\(n)"
}
1 Answer
Jennifer Nordell
Treehouse TeacherFirst, I'm going to try with some hints. And we'll see if you can get it done Part of the problem here lies in the requirements of the challenge. While your code might be functional outside the challenge it won't work here. A switch statement requires a default. And the challenge instructions say this:
Do not worry about the default case (where the number doesn't match Fizz, Buzz, or FizzBuzz). The code in the challenge editor already takes care of that by returning the number as a string using string interpolation.
So this entire thing should be written as if
and else if
statements.
Also, this challenge specifically says that you should not print anything. All of these strings are to be returned:
Change all your print statements to return statements. For example: print("FizzBuzz") becomes return "FizzBuzz".
Give this another shot with these tips in mind!