Reputation:
I have two arrays, one full of links and another one of domains of which shall be removed from the first array.
array1 = [ http://www.linkone.com, https://www.linktwo.com, ... ]
array2 = [ 'linkone' ]
The second array does not have the format of a URL, I've done this by doing the following:
for (let a2 of array2) {
clearedUrls.push(_.pull(array1, `https?:\/\/www.${a2}.*`))
}
It worked, but the output of clearedUrls
contains array inside of array:
[
'https://www.foo.com',
'https://www.foo.com',
'https://www.foo.com',
'https://www.foo.com',
[
'https://www.foo.com',
'https://www.foo.com',
'https://www.foo.com',
],
[ ... ]
]
I know it's because every iteration it will push
. I'd like to know a better way to loop over the array2
, remove the URLs from array
, and return the array with only links inside, no more arrays.
Upvotes: 0
Views: 48