Putting the String issue aside, I just wanted to show the beauty of pattern matching. for i in range(1i, 101) { match (i % 3, i % 5) { (0, 0) => println!("Fizzbuzz"), (0, _) => println!("Fizz"), (_, 0) => println!("Buzz"), _ => println!("{}", i), } } -- edited: removed `.to_string()`, thanks chrismorgan
function fizzBuzz(i) {
switch(i % 15) {
case 0: return "fizbuzz";
case 5:
case 10: return "buzz";
case 3:
case 6:
case 9:
case 12: return "fizz";
default: return i.toString();
}
}
[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15].map(fizzBuzz)