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:6
Explanation:

Adding together only the even numbers in the list gives 6.

Input:nums = [5,5,5]
Output:0
Explanation:

Adding together only the even numbers in the list gives 0.

Input:nums = [-2,-4,3,10]
Output:4
Explanation:

Adding together only the even numbers in the list gives 4.

Constraints

  • 1 ≤ nums.length ≤ 10⁴
  • -10⁴ ≤ nums[i] ≤ 10⁴

Ready to solve this problem?

Practice solo and sharpen your skills for technical interviews.