← Back to challenges

Minimum Removals to Make Sum Even

JavaScriptHardarrayshigher_order_functionsloops

Instructions

Create a function that returns the minimum number of removals to make the sum of all elements in an array even.

Examples

minimumRemovals([1, 2, 3, 4, 5]) ➞ 1

minimumRemovals([5, 7, 9, 11]) ➞ 0

minimumRemovals([5, 7, 9, 12]) ➞ 1

Notes

  • If the sum is already even, return 0 (see example #2).
  • The output will be either 0 or 1.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Is Sam with Frodo?