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 aboutaleb
4,025 PointsCant get this right... i have checked all the discussions and i cant get it!! Can any one help?
ughhh
if (n % 3 == 0) && (n % 5 == 0) { return ("FizzBuzz") }
else if (n % 3 == 0) { return ("Fizz") }
else if (n % 5 == 0) { return ("Buzz") }
2 Answers
Alex Busu
Courses Plus Student 11,819 PointsHey there, why are you putting brackets on your strings. Also for this solution if I can make a suggestion, try to add strings together instead of hard checking for all possible combinations. e.g.
var result = ""
if(n%3 == 0) { result+="Fizz" }
if(n%5 == 0) { result+="Buzz" }
result.count > 0 ? result : "\(n)"
Dave Harker
Courses Plus Student 15,510 PointsHi ali aboutaleb,
Couldn't see anything wrong so I literally copied your code and pasted it into the challenge between the comments they designated. Worked without issue.
Perhaps try again? Happy coding,
Dave