Okay, so i have a task to find the sum of the members of even numbers in an array that are >0 . How can I form the code in js?
You can use the filter method.
filter
This means you write something like:
arr.filter(x => x % 2 === 0).reduce((a, b) => a + b, 0)
where arr is your array of numbers.
arr
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Okay, so i have a task to find the sum of the members of even numbers in an array that are >0 . How can I form the code in js?
You can use the
filter
method.This means you write something like:
where
arr
is your array of numbers.