I wrote another blog post, this time about how I solved the “Seek and Destroy” JavaScript Coding Challenge.
I really hope this will be useful for the community!
If you have any questions or concerns, let me know and I’d be happy to help!
I wrote another blog post, this time about how I solved the “Seek and Destroy” JavaScript Coding Challenge.
I really hope this will be useful for the community!
If you have any questions or concerns, let me know and I’d be happy to help!
No .reduce()
??? Disliked, blocked, unfollowed
Also have you heard the word of our lord and savior ...
(i.e. rest operator)?
function destroyer(arr, ...rest) {
return arr.filter(n => !rest.includes(n))
}
(I know it says you have to use arguments
, but it’s not enforced )
Yeah… I followed the rules. I’m not a felon!!
Hmm… I forgot about the includes
… my bad. Thanks for the addition @jenovs! Great as always! except that you are breaking the rules! :cough:
function destroyer() {
const [arr, ...rest] = arguments;
return arr.filter(n => !rest.includes(n))
}
Better?
Hmm… nope. I think my solution is better. Check this out:
const destroyer = (arr, ...rest) =>
arr.reduce(
(acc, curr) => (!rest.includes(curr) ? [...acc, curr] : acc),
[]
);
So good that I think I have to update the blog post and add it!