Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for [old] Fizz Buzz by Drakeno
"use strict";
function fizzBuzz(data) {
if (data % 3 === 0 && data % 5 === 0) return "Fizz Buzz";
if (data % 3 === 0) return "Fizz";
if (data % 5 === 0) return "Buzz";
return data.toString();
}
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. 19, 2018