Skip to content
Advertisement

Remove item by its value from array inside a loop

Given this working code:

JavaScript

How would you optimize the “Clean up the input array” phase? Is there a way to delete all the items in the input array those matches the if condition?

Thanks everyone

Advertisement

Answer

Yes, add a key to the initial foreach and use it to unset the value in the input array you are adding to the ban list.

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement