← Back to challenges

Just Another Sum Problem But... 😰😱

JavaScriptHardalgebraalgorithmslanguage_fundamentals

Instructions

Ok, the challenge is kind of easy, right?

The problem is not adding. The problem is that the numbers are not in order. Create a function that organizes the numbers and adds the numbers in the range between X and Y.

Here is an example:

X = -10 | Y=1

So this will be the range of numbers:

-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1

This will be your result:

-54

Remember, X and Y are disorganized, so to get to the result you know what you have to do.

Examples

justAnotherSumProblem(-10, 1) ➞ -54

justAnotherSumProblem(-20, 5) ➞ -195

justAnotherSumProblem(90, 45) ➞ 3105
javascript
Loading editor…
⌘ ↡ to run
Walks through the solution with reasoning and edge cases.
Next: Human, Cat and Dog Years πŸ§‘πŸ»πŸ±πŸΆ β†’