sum of odd numbers in an array javascript without loop
var numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
var evenNumbers = numbers.filter(function(item) {
return (item % 2 == 0);
});
console.log(evenNumbers);var total = numbers.reduce(function(total, current) {
return total + current;
}, 0);
console.log(total);
Also in JavaScript:
- how to decode apollo client graphql error: bad request
- change js to json
- switch alert
- react grid
- return this javascript
- percentage formula in javascript
- can I pass function as prop on route change
- python json from csv
- converting bytes into kb js
- remove last character from string jquery
- react native async storage
- javascript play audio
- JavaScript Operator Precedence Values
- show preview of input image javascript react
- javascript square root
- how to check if a string has only alphabets in javascript
- check if word is in string javascript
- split a message js
- chart js radar grid color
- fullscreen electron
- round number 2 decimals javascript
- js string replace
- Parallax.js wrapper for react
- get the last option from select jquery