Skip to content

Commit

Permalink
fix(arrays): removeFromArray always returns a copy
Browse files Browse the repository at this point in the history
  • Loading branch information
simonhaenisch committed Jun 1, 2020
1 parent fc57998 commit 4acb473
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/arrays/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const getArraySum = (array: number[]) => array.reduce((acc, val) => acc +
export const removeFromArray = <T>(array: T[], el: T) => {
const i = array.indexOf(el);

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)];
};

/**
Expand Down

0 comments on commit 4acb473

Please sign in to comment.