sum in javascript
const arr = [1, 2, 3, 4];
const sum = arr.reduce((a, b) => a + b, 0);
// sum = 10const sum = arr => arr.reduce((a, b) => a + b, 0);[1, 2, 3, 4].reduce((a, b) => a + b, 0)
// Output: 10console.log(
[1, 2, 3, 4].reduce((a, b) => a + b, 0)
)
console.log(
[].reduce((a, b) => a + b, 0)
)const arrSum = arr => arr.reduce((a,b) => a + b, 0)1.500,25
Also in JavaScript:
- fa icons react
- how to define variable in javascript
- kill all node processes
- function isValidWalk(walk)
- navlink activestyle not working
- comment in jsp file
- first element of array js
- jquery close another dialog
- how to display current date and time in angular
- check if anagram
- cli run js
- get start of day javascript
- get current directory vbscript
- how to prevent event capturing in javascript
- json object check if key exists java
- javascript get intersection of two arrays
- javascript return value from async function site:stackoverflow.com
- activate an event on press escape button in jquery
- ionic 1 decorator example
- slice in javascript
- selector id jquery but is variable
- pandas to json
- arrow function in javascript
- jason rpc reactjs