Practice
JavaScriptData StructuresReactConcepts
Sign in
← Back to problems

Sum of Even Arguments

A Closer Look at Functionsmedium

Course · Section 10: A Closer Look at Functions · Lecture 135: Default Parameters

Implement `sumEvenArgs(...nums)` returning the sum of only the even arguments.

Sample tests

Input: sumEvenArgs(1, 2, 3, 4)
Output: 6
Input: sumEvenArgs(1, 3)
Output: 0

+ 1 hidden test run on Submit.

Hints

Common pitfalls
  • Negative even numbers still count as even (sign does not affect parity).

Learning resources

  • MDN: Functions
Approach & explanation (try first)

Rest collects the arguments, filter keeps the evens, and reduce sums them.

Loading...
⌘/Ctrl + Enter

Run your code to see results.