Now, we have this recursive function:
function digitsMultipication(number) {
let strNumber = number.toString();
let firstNum = parseInt(strNumber[0]);
if(strNumber.length==1){
return firstNum
}else{
let x = ''
for(i=1;i<strNumber.length;i++){
x += strNumber[i]
}
x = parseInt(x)
return firstNum * digitsMultipication(x);
}
}
// TEST CASES
console.log(digitsMultipication(66)); // 36
How do we edit this function since we want the output condition is literally one digit. Because 36 is still 2 digits and we want the function recursed again until the output is one digit, which is 8.
66 => 6 * 6 = 36,
36 => 3 * 6 = 18,
18 => 1 * 8 = 8 (the wanted final output)