Created
April 2, 2019 22:14
-
-
Save thekarel/b0f9efcbecca07b54cfe093aad24ff6a to your computer and use it in GitHub Desktop.
Omit an array element
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {omit} from './omit' | |
describe(`Omit`, () => { | |
it(`removes item with index from array`, async () => { | |
const arr = [1, 2, 3] | |
expect(omit(0, arr)).toEqual([2, 3]) | |
}) | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const omit = (n: number, arr: any[]) => [ | |
...arr.slice(0, n), | |
...arr.slice(n + 1), | |
] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment