DEV Community

Discussion on: Daily Challenge #195 - No Zeroes for Heroes

Collapse
 
zenmumbler profile image
zenmumbler

I find it interesting that every solution here uses strings, here's one acting on the numbers itself. (tested against the above and other values).

function deathToZeroes(n) {
    while ((Math.abs(n) > 9) && (n % 10 === 0)) {
        n /= 10;
    }
    return n;
}
Enter fullscreen mode Exit fullscreen mode