Sum of Even Numbers
EasyArrayMath
Description
Given an array of integers nums, return the sum of the values that are even.
Examples
Input:
nums = [1,2,3,4]Output:
6Explanation:
Adding together only the even numbers in the list gives 6.
Input:
nums = [5,5,5]Output:
0Explanation:
Adding together only the even numbers in the list gives 0.
Input:
nums = [-2,-4,3,10]Output:
4Explanation:
Adding together only the even numbers in the list gives 4.
Constraints
- •
1 ≤ nums.length ≤ 10⁴ - •
-10⁴ ≤ nums[i] ≤ 10⁴