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 trialSantiago Srz
6,631 PointsFizzBuzz
I don't know whats wrong with my code, if somebody can help me.. thank you !!
var numbers = 1...50
func fizzBuzz(n: Int) -> String {
// Enter your code between the two comment markers
for n in numbers{
if n % 3 == 0 && n % 5 == 0 {
print("FizzBuzz")
} else if n % 5 == 0 {
print("Buzz")
} else if n % 3 == 0 {
print("Fizz")
} else {
print(n)
}
}
// End code
return "\(n)"
}
1 Answer
Andrew Dummer
6,885 PointsThere are a couple of instructions you might have missed: 1. "The challenge does not need a loop" and you have a for loop in your code. 2. " Change all your print
statements to return
statements" and currently you have print
statements in your code 3. "Do not worry about the default case" so you can take the else
block out.
Santiago Srz
6,631 PointsSantiago Srz
6,631 PointsPerfect andrew thanks !!!