total array with function
console.log(
[1, 2, 3, 4].reduce((a, b) => a + b, 0)
)
console.log(
[].reduce((a, b) => a + b, 0)
)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:
- toggle jquery remove others
- capitalize in javascript
- how to run a cloned react native project
- reverse a linked list javascript
- js create object url base64 pdf binary
- eslint ignore current line
- counter composant react
- mongoose update array in object
- js select all
- dark mode with react hooks
- string repeat javascript
- event exit fullscreen
- cannot create an instance of an abstract class httphandler angular
- how to declare variables javascript
- "when.promise" async await
- jquery remove css
- user agents regex for mobile
- class component react
- discord js stats command
- js random id
- remove first char javascript
- jquery show hide based on data attribute
- store data in localstorage chrome as per address bar url using javascript
- How to check if a member has a role discord.js