← Back to challenges

Mirror Array

JavaScriptHardarraysnumberslogic

Instructions

Given an integer array, transform that array into a mirror.

Examples

mirror([0, 2, 4, 6]) ➞ [0, 2, 4, 6, 4, 2, 0]

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

mirror([3, 5, 6, 7, 8]) ➞ [3, 5, 6, 7, 8, 7, 6, 5, 3]

Notes

Do not repeat the last item of the given array.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: A Long Long Time