Implement function switchPlaces
which switches places of values with index index1
and index2
in arr
. Function should return new array. Original array arr
should not be modified. Return unmodified copy of arr
if one of index1
or index2
is invalid (for example outside of array length).
switchPlaces(['uno', 'tuo', 'tre'], 0, 3)