DEV Community

loading...

Discussion on: Daily Challenge #11 - Cubic Numbers

Collapse
elliot profile image
Elliot

Primary Objective Code golf-ished:

const isCubic = number => (
                            number < 1000 && 
                            ('' + number).split('').map(
                              n => parseInt(n)
                            ).reduce(
                              (a, c) => a + c ** 3, 
                              0
                            ) === number
                          )? 1 : null;

P.S. @thepracticaldev , I think the secondary objective example 1 output is incorrect:

s = “aqdf& 0 1 xyz 153 777.777" should return “0 1 153 154”

The 154 shouldn't be there, right?

Collapse
deciduously profile image
Ben Lovy

Seems like it was supposed to be in the input, not expected output.