mirror of
https://github.com/expo/expo-cli.git
synced 2026-11-14 18:06:30 -10:00
7 lines
170 B
JavaScript
7 lines
170 B
JavaScript
export const swap = (a, x, y) => {
|
|
if (a.length === 1) return a;
|
|
const result = [...a];
|
|
result.splice(y, 1, result.splice(x, 1, result[y])[0]);
|
|
return result;
|
|
};
|