Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
FizzBuzz solution in Clear category for [old] Fizz Buzz by ramzahn
"use strict";
function fizzBuzz(data) {
if ((data % 3 === 0) && (data % 5 === 0)) {
return 'Fizz Buzz';
}
else if (data % 3 === 0) {
return 'Fizz';
}
else if (data % 5 === 0) {
return 'Buzz';
}
else {
return String(data);
}
}
var assert = require('assert');
if (!global.is_checking) {
assert.equal(fizzBuzz(15), "Fizz Buzz", "15 is divisible by 3 and 5");
assert.equal(fizzBuzz(6), "Fizz", "6 is divisible by 3");
assert.equal(fizzBuzz(5), "Buzz", "5 is divisible by 5");
assert.equal(fizzBuzz(7), "7", "7 is not divisible by 3 or 5");
console.log("Coding complete? Click 'Check' to review your tests and earn cool rewards!");
}
Aug. 30, 2019
Comments: