SyntaxFix
Write A Post
Hire A Developer
Questions
Here is the best solution I found:
function digitsum(n) { n = n.toString(); let result = 0; for (let i = 0; i < n.length; i++) { result += parseInt(n[i]); } return result; } console.log(digitsum(192));