Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to loop and add number in fuction for javascript


//The ... is the Rest parameter
function sum(...numbers) {
    return numbers.reduce((total, individualNum) => total + individualNum)
}
// OR
function sum(...numbers) {
    return numbers.reduce(function (total, individualNum) {
        return total + individualNum
    })
}
 
PREVIOUS NEXT
Tagged: #loop #add #number #fuction #javascript
ADD COMMENT
Topic
Name
9+6 =