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 trialJordan Ward
2,395 PointsHey guys, I don't understand why This isn't passing. Any tips?
Hey guys, I don't understand why This isn't passing. Any tips?
My answer is almost identical to the video, all ive done differently is change the print to return like instructed too.
func fizzBuzz(n: Int) -> String {
for n in 1...100 {
if (n % 3 == 0) && (n % 5 == 0) { return "FizzBuzz"
} else if (n % 3 == 0) { return "Fizz"
} else if (n % 5 == 0) { return "Buzz"
} else {
return }
}
2 Answers
Jeff McDivitt
23,970 PointsHi Jordan - You are missing the final return
func fizzBuzz(n: Int) -> String {
// Enter your code between the two comment markers
if (n % 3 == 0) && (n % 5 == 0) {
return("FizzBuzz")
} else if (n % 3 == 0) {
return ("Fizz")
} else if (n % 5 == 0) {
return("Buzz")
} else {
return("n")
}
// End code
}
Jeff McDivitt
23,970 PointsHi Jordan - Yes I have an app on the App Store, it is called wrench conversions. It has a pickerView and picks a standard wrench size and gives you the metric equivalent.
As for your other questions, it has the quotations around it because it is a string. If you try to submit it without them you will get an error because you cannot convert string to Int or something like that
Jordan Ward
2,395 PointsJordan Ward
2,395 Pointswow haha thats pretty silly, thanks Jeff! You have quite the score in IOS your obviously pretty good at coding swift, ever built your own app and uploaded to the App Store?
Jordan Ward
2,395 PointsJordan Ward
2,395 PointsAlso why does n have quotation marks in final return? Shouldn't it be return(n) ?