Search
 
SCRIPT & CODE EXAMPLE
 

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);
Comment

sum of odd numbers in an array javascript without loop

var total = numbers.reduce(function(total, current) {
    return total + current;
}, 0);

console.log(total);
Comment

PREVIOUS NEXT
Code Example
Javascript :: jquery check if document loaded 
Javascript :: google recaptcha reload 
Javascript :: ipcrenderer main.js 
Javascript :: javascript calculate average of array 
Javascript :: cypress get inut value 
Javascript :: moment set time 
Javascript :: what is redux 
Javascript :: professional react projects 
Javascript :: add decimals javascript 
Javascript :: ajax data not reflecting after refresh particular div jquery 
Javascript :: jquery checkbox group selected value 
Javascript :: mongodb text search 
Javascript :: javascript return string 
Javascript :: get param is react 
Javascript :: concat array javascript 
Javascript :: init select2 jquery 
Javascript :: jquery dropdown selected value show field 
Javascript :: js remove specific item from array 
Javascript :: object has property 
Javascript :: max js 
Javascript :: disable other options in select except the selected 
Javascript :: javascript console.table 
Javascript :: react key press hook 
Javascript :: delete element javascript 
Javascript :: discord.js clear console 
Javascript :: random function in javascript 
Javascript :: javascript array contains 
Javascript :: angular detect chromebook 
Javascript :: find max value in javascript 
Javascript :: js binary 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =