Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to break from map in javascript

let isBroken = false;

colours.map(item => {
    if (isBroken) {
        return;
    }
    if (item.startsWith("y")) {
        console.log("The yessiest colour!");
        isBroken = true;
        return;
    }
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #break #map #javascript
ADD COMMENT
Topic
Name
5+8 =