Skip to content

Instantly share code, notes, and snippets.

@thekarel
Created April 2, 2019 22:14
Show Gist options
  • Save thekarel/b0f9efcbecca07b54cfe093aad24ff6a to your computer and use it in GitHub Desktop.
Save thekarel/b0f9efcbecca07b54cfe093aad24ff6a to your computer and use it in GitHub Desktop.
Omit an array element
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])
})
})
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