Sometimes, we want to add break statement in JavaScript array map method.
In this article, we’ll look at how to add break statement in JavaScript array map method.
How to add break statement in JavaScript array map method?
To add break statement in JavaScript array map method, we can use the array some
method.
For instance, we write
const hasValueLessThanTen = myArray.some((val) => {
return val < 10;
});
to call myArray.some
with a callback that checks if any items in myArray
has value less than 10.
Conclusion
To add break statement in JavaScript array map method, we can use the array some
method.