(x+'').split('')
또는 [...x.toString()]
function solution(x) {
let sum = (x+'').split('').reduce((a,i) => { return a += i*1 }, 0);
if (x % sum*1 === 0) {
return true
} else {
return false
}
}
function solution(x) {
let num = x;
let sum = 0;
do {
sum += x%10;
x = Math.floor(x/10);
} while (x>0);
return !(num%sum);
}