So you nest includes() which loops thru array2 inside forEach(), which is not ideal in terms of time complexity if you have a huge amount of items in your arrays.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi! Hace you considered using the .includes() method? If not, can you tell me why? I'm kind of new to JS.
Thanks for your article!
Hi Mike yes you totally can use
includes()
however it would make the function not algorithm-wise because you gotta nest one loop inside another:So you nest
includes()
which loops thru array2 insideforEach()
, which is not ideal in terms of time complexity if you have a huge amount of items in your arrays.