Write a function removeAt(items, index) that returns a new array without the element at index index. Do not change the original array and do not use splice. If the array has no such index, return an unchanged copy of it.
removeAt([10, 20, 30, 40], 1)Returns [ 10, 30, 40 ]
removeAt([1, 2, 3], 3)Returns [ 1, 2, 3 ]
removeAt(['a', 'b'], -1)Returns [ 'a', 'b' ]
Asked at Microsoft · Source
removeAt([ 10, 20, 30, 40 ], 1)[ 10, 30, 40 ]removeAt([ 1, 2, 3 ], 3)[ 1, 2, 3 ]removeAt([ 'a', 'b' ], -1)[ 'a', 'b' ]Hidden tests run on Submit.