Skip to content
Advertisement

Can a some() function replace nested forEach()?

I need to replace two (nested) forEach loops with a some function. The purpose of the code block is to check if the [1] elements in arrayOne are within the max & min of arrayTwo.

The code currently works fine and looks like this:

JavaScript

Let me know if it isn’t clear enough. Really appreciate your help.

Advertisement

Answer

Yes, you can use Array#some in this situation. It would be done like this

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