When I wrote a piece of code and tested it in my editor, everything seemed to be working fine. However, upon uploading it to codewars, an error with the following message popped up: "TypeError: n.split is not a function."
I attempted to use "n.toString()" based on suggestions from other sources but unfortunately, it did not solve the issue. What mistake could I have made?
"use strict"
let sum = 0;
function digital_root(n) {
n.toString();
let arr =
(n).split("").map(Number);
for(let i=0; i < arr.length; i++) {
sum += arr[i];
}
return sum;
}
console.log(digital_root("16"));