Linked Questions
11 questions linked to/from Break statement in javascript array map method
2244 votes
32 answers
1.9m views
Short circuit Array.forEach like calling break
[1,2,3].forEach(function(el) { if(el === 1) break; }); How can I do this using the new forEach method in JavaScript? I've tried return;, return false; and break. break crashes and return does ...
0 votes
1 answer
452 views
Is there a way to return from the containing block of a map in Javascript? [duplicate]
I'm trying to implement a function which checks whether a list of letters are all present in a word. function wordHasLatters(word,letters){ let wordChars={}; word.split("").map(c=>...
0 votes
1 answer
112 views
How to return from a higher function [duplicate]
For example: function foo() { someArray.map(bar) { if (whatever) return; // I want to return from the foo function return bar.something // Here I return to map function } } Here is ...
0 votes
0 answers
39 views
How to stop executing map function on array index 5 in javascript [duplicate]
I have array of 10 elements, I am mapping to extract array data . I want to stop array executing when compile reached to array index 5 . I know it possible with for loop but I need it in map function. ...
14 votes
4 answers
57k views
Break out of map
so i have this problem where if the value in the array is higher than entered value it should do something and then stop the loop and don't touch the remaining values in the array.. Here's the code so ...
-1 votes
1 answer
2k views
stop performing map function on state if certain condition for one time is met
this.state = { glasses :[{id:0,,value:100, show:true,}, {id:1,,value:150, show:false}, {id:2, value:200, show:true,}, ...
0 votes
3 answers
1k views
How to break a loop inside inline if in next js
I would like to stop the loop inside bedsAssign.map if row.id is not equal to u.tenant_id but putting break; doesn't work. {tenants.map((row) => bedsAssign.map( (...
0 votes
1 answer
2k views
How to terminate loop in map function in React js
I have a jsx component to show blog in home page,3 division blog post will be shown and other new packages will be viewed by clicking view more button. My problem is adding more 5 blog post, button is ...
1 vote
1 answer
772 views
Break the loop in the map function and move
So basically im working on a cron job in my app that fires every 3 hours and updating users 'score' by calling the RiotApi basically the function so far exports.updatePlayersPoints = async () => { ...
-1 votes
1 answer
97 views
Javascript loop not returning true, when String === String
When looping through an array to find if the array contains a word that I am looking for, the loop always returns 'false' when if I console.log out the what is being compared I can clearly see that ...
0 votes
1 answer
83 views
jQuery - Selectively storing table data to 2d array
I came up with the problem of storing html table data to a 2D array. Instead of using nested loops, I was looking for jquery functions that would allow me to do the same. I found this method which ...