Search
 
SCRIPT & CODE EXAMPLE
 

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
    })
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: committing parts of a file git 
Javascript :: jquery event element is visible 
Javascript :: clear session storage on refresh 
Javascript :: javascript remove event listener 
Javascript :: js string array convert to int 
Javascript :: clean react app 
Javascript :: JAVASCRIPT ARRRAY LOOP BACKWARDS 
Javascript :: javascript round to nearest 10 
Javascript :: select add option js 
Javascript :: express redirect to url 
Javascript :: angular call function on option select 
Javascript :: click outside box jquery 
Javascript :: create infinite loop using for loop in javascript 
Javascript :: javascript split string only on first instance of specified character 
Javascript :: Module Error (from ./node_modules/eslint-loader/dist/cjs.js): 
Javascript :: get cookie value in javascript 
Javascript :: clear localstorage on click jquery 
Javascript :: vue.js function to always uppercase when the client input lowercase 
Javascript :: jquery click outside 
Javascript :: uppercase in word javascript 
Javascript :: react bootstrap card 
Javascript :: google oauth logout 
Javascript :: split date in javascript 
Javascript :: set cursor type javascript 
Javascript :: keypress javascript 
Javascript :: FullScreen Image By OnClick Jquery 
Javascript :: jest testmatch specific folder 
Javascript :: js poll dom 
Javascript :: get id of first td jquery 
Javascript :: get id of clicked element javascript 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =