Monday, February 25, 2019

Sum Total Integer

Total sum Total sum
var value = 2568,

    sum = value
        .toString()
        .split('')
        .map(Number)
        .reduce(function (a, b) {
            return a + b;
        }, 0);

document.querySelector('p').innerHTML= sum;

alert(sum);

Total sum Total sum to 1 digit



var value=2568;

function sum(value){
    var sum=value.toString().split("")
                 .reduce(function(a,b) {
                  return a+parseInt(b);
                  },0);
    return sum;
}

while(value > 9){
    value=sum(value);
}

Variable


Operator

Arithmetic Operators

OperatorDescription
+Addition
-Subtraction
*Multiplication
/Division
%Modulus (remainder of a division)
++Increment
--Decrement

Assignment Operators

OperatorDescription
=Assign
+=Add and assign. For example, x+=y is the same as x=x+y.
-=Subtract and assign. For example, x-=y is the same as x=x-y.
*=Multiply and assign. For example, x*=y is the same as x=x*y.
/=Divide and assign. For example, x/=y is the same as x=x/y.
%=Modulus and assign. For example, x%=y is the same as x=x%y.

Comparison Operators

OperatorDescription
==Is equal to
===Is identical (is equal to and is of the same type)
!=Is not equal to
!==Is not identical
>Greater than
>=Greater than or equal to
<Less than
<=Less than or equal to

Logical/boolean Operators

OperatorDescription
&&and
||or
!not

String Operators

In JavaScript, a string is simply a piece of text.
OperatorDescription
=Assignment
+Concatenate (join two strings together)
+=Concatenate and assign
You will learn how to use some of the most common of these JavaScript operators in the following pages.

Sum Total Integer

Total sum Total sum var value = 2568,     sum = value         .toString()         .split('')         .map(Number)         ...