← Back to challenges

Give Me the Even Numbers

JavaScriptHardloopsmathnumbers

Instructions

Create a function that takes two parameters (start, stop), and returns the sum of all even numbers in the range.

Examples

sumEvenNumsInRange(10, 20) ➞ 90
// 10, 12, 14, 16, 18, 20

sumEvenNumsInRange(51, 150) ➞ 5050

sumEvenNumsInRange(63, 97) ➞ 1360

Notes

Remember that the start and stop values are inclusive.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Cowboy Shootout