DEV Community

loading...

Discussion on: Daily Challenge #214 - Persistent Bugger

Collapse
sabbin profile image
Sabin Pandelovitch

JS solution

function persistance(num){
  let n = num;
  let count = 0;
  while(n > 9){
    count++;
    n = [...String(n)].map(Number).reduce((a,v)=> a*v,1)
  }
  return count
}