![]() Now, we did a simple comparison–what if we wanted to compare based on cost, or based on whether anyone in our group is a vegan, or on a complex multi-factor analysis? Ok, today you feel like sushi, so Lucky Robot wins round 1. “Lucky Robot” > “Ramen Tatsuya” ? “Lucky Robot” : “Ramen Tatsuya” One way to handle that problem is to just take two of them, and decide: which one would you pick between these two? If you’re like me, you may have used the reduce algorithm in your mind to help you make a choice. Array.reduce() can be a little unintuitive at first encounter, so here’s my best shot at a gentle introduction. If you want to perform map() and filter() in a single loop, the way to do that would be reduce(). ![]() The problem is that filtered out items still uses space in the array and I would like to completely wipe them out. I would like to filter an array of items by using the map() function.
0 Comments
Leave a Reply. |