Linked Questions

2244 votes
32 answers
1.9m views

[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 ...
Scott Klarenbach's user avatar
0 votes
1 answer
452 views

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=>...
sbtpr's user avatar
  • 561
0 votes
1 answer
112 views

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 ...
Adam Kettani's user avatar
0 votes
0 answers
39 views

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. ...
Jonas's user avatar
  • 159
14 votes
4 answers
57k views

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 ...
Benas Lengvinas's user avatar
-1 votes
1 answer
2k views

this.state = { glasses :[{id:0,,value:100, show:true,}, {id:1,,value:150, show:false}, {id:2, value:200, show:true,}, ...
user avatar
0 votes
3 answers
1k views

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( (...
John Michael Vicmudo's user avatar
0 votes
1 answer
2k views

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 ...
Gu Gue's user avatar
  • 189
1 vote
1 answer
772 views

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 () => { ...
A. Atiyah's user avatar
  • 555
-1 votes
1 answer
97 views

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 ...
Andrew's user avatar
  • 33
0 votes
1 answer
83 views

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 ...
user avatar