← Back to challenges

Additive Inverse

JavaScriptHardarraysmathhigher_order_functionsloops

Instructions

A number added with its additive inverse equals zero. Create a function that returns an array of additive inverses.

Examples

additiveInverse([5, -7, 8, 3]) ➞ [-5, 7, -8, -3]

additiveInverse([1, 1, 1, 1, 1]) ➞ [-1, -1, -1, -1, -1]

additiveInverse([-5, -25, 35]) ➞ [5, 25, -35]
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Return First and Last Parameter