+ 1
Digit Number Javascript (Help me please)
Do you guys know the javascript method to add up the number digits? For example I have: var number = 1234; , I want to add that digit.
1 ответ
+ 3
var number = 1234;
var sum = 0;
while (number>0){
sum+=number%10;
number/=10;
number = floor(number);
}