function g(num) { if (num < 10) return num; const next = ('' + num).split('').reduce((a, c) => +a + +c); return g(next); } console.log(g(448));