We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
removeFromArray
1 parent fc57998 commit 4acb473Copy full SHA for 4acb473
src/arrays/index.ts
@@ -31,7 +31,7 @@ export const getArraySum = (array: number[]) => array.reduce((acc, val) => acc +
31
export const removeFromArray = <T>(array: T[], el: T) => {
32
const i = array.indexOf(el);
33
34
- return i === -1 ? array : [...array.slice(0, i), ...array.slice(i + 1)];
+ return i === -1 ? array.slice() : [...array.slice(0, i), ...array.slice(i + 1)];
35
};
36
37
/**
0 commit comments