DEV Community

loading...

Discussion on: Daily Challenge #156 - Dave's Gamble

Collapse
wheatup profile image
Hao

JavaScript

const horses = count => Number.isInteger(count) ? (
    count < 3 ? count : count * (count - 1) * (count - 2)
) : undefined;

console.log(horses(2));     // 2
console.log(horses(15));    // 2730
console.log(horses(13.37)); // undefined