Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Creative category for [old] Fizz Buzz by Daniel_Pereira
'use strict';
var assert = require('assert');
function fizzBuzz(data) {
return [
data % 3 === 0 && 'Fizz' || '',
data % 5 === 0 && 'Buzz' || ''
].join(' ').trim() || data.toString();
}
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!");
}
June 23, 2016