← Back to challenges

Invert an Array

JavaScriptHardarraysfunctional_programminglanguage_fundamentalsinterview

Instructions

Create a function that takes an array of numbers arr and returns an inverted array.

Examples

invertArray([1, 2, 3, 4, 5]) ➞ [-1, -2, -3, -4, -5]

invertArray([1, -2, 3, -4, 5]) ➞ [-1, 2, -3, 4, -5]

invertArray([]) ➞ []
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Lowercase, Uppercase or Mixed?