From c8bf4e197d1e07bfd162bb2e7acd2147ce6561d9 Mon Sep 17 00:00:00 2001 From: King Date: Wed, 20 Dec 2017 22:43:33 -0500 Subject: [PATCH] before hacky -> now elegant --- snippets/pull.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/snippets/pull.md b/snippets/pull.md index 16f0e25c4..41658a545 100644 --- a/snippets/pull.md +++ b/snippets/pull.md @@ -9,8 +9,10 @@ _(For a snippet that does not mutate the original array see [`without`](#without ```js const pull = (arr, ...args) => { - let pulled = arr.filter((v, i) => !args.toString().split(',').includes(v)); - arr.length = 0; pulled.forEach(v => arr.push(v)); + let argState = Array.isArray(args[0]) ? args[0] : args; + let pulled = arr.filter((v, i) => !argState.includes(v)); + arr.length = 0; + pulled.forEach(v => arr.push(v)); }; // let myArray1 = ['a', 'b', 'c', 'a', 'b', 'c'];