sum of odd numbers in an array javascript
///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:
- (!+[]+[]+![]).length 9
- How many different types of JS alerts do we have?
- get element by id in javascript
- get current week number javascript
- javascript .tolowercase
- javascript get hour from date
- js add item to array
- format JSON code javascript
- formating decimal hours as hours and minute javascript
- multiple image upload with preview and delete react js
- javascript project ideas
- binary to int javascript
- join array js
- js redirect to url
- angularjs accordion access toggle
- setinterval jquery
- array in javascript
- can we add new state property using setstate in react
- promise catch
- Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function.
- angular 7 folder structure best practices
- how to remove 000webhost watermark 2019
- how to delay something in javascript
- parseint js