DEV Community

loading...

Discussion on: Daily Challenge #214 - Persistent Bugger

Collapse
_bkeren profile image
''

JS

const persistence = (num, result =0) => {
    const str = `${num}`
    if(str.length === 1) return result;
    const mult = str.split("").reduce((a,b) => a * b)
    return persistence(mult , result + 1)
}