Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
One liner with spread & ternary ... solution in Creative category for [old] The Most Numbers by sweatC
"use strict";
function mostNumbers(...numbers){
return numbers.length === 0? 0 :
Math.max(...numbers) - Math.min(...numbers);
}
var assert = require('assert');
if (!global.is_checking) {
assert.equal(mostNumbers(1, 2, 3), 2, "3-1=2");
assert.equal(mostNumbers(5, -5), 10, "5-(-5)=10");
assert.equal(Math.round(mostNumbers(10.2, -2.2, 0, 1.1, 0.5)*1000), 12400, "10.2-(-2.2)=12.4");
assert.equal(mostNumbers(), 0, "Empty");
console.log("Coding complete? Click 'Check' to review your tests and earn cool rewards!");
}
Jan. 27, 2017
Comments: