Javascript get sum of array values
arr.reduce((a, b) => a + b)function getArraySum(a){
var total=0;
for(var i in a) {
total += a[i];
}
return total;
}
var payChecks = [123,155,134, 205, 105];
var weeklyPay= getArraySum(payChecks); //sums up to 722
Also in JavaScript:
- hide show jquery
- how to empty form after submit react
- javascript format date yyyy-mm-dd hh:mm:ss to dd-mm-yyyy hh:mm am/pm
- foreach async typescript
- how to set json type jquery ajax
- denuncia perturbação
- javascript falsy values
- bring to front svg html
- cannot concatenate object of type "<class 'str'>"; only pd.Series, pd.DataFrame, and pd.Panel (deprecated) objs are valid
- javascript ajax post send an object
- filter
- js get alphabet as array
- js scroll to bottom of element
- how to find a name of class from page in jquery
- place white and black knights on 2x2 chessboard
- vendor bundle base js and bootstrap min js conflict
- javascript yield
- array.unshift in javascript
- angular maxlength directive input type number
- js shortcut
- exponent in javascript
- filter an array of objects and match its key with values inside another array
- Returning Boolean Values from Functions
- event.persist()