DEV Community

Discussion on: Daily Challenge #220 - What Dominates Your Array?

Collapse
le_newtype profile image
Nicholas ―M― • Edited on

Here's my solution in JavaScript. I'm not sure how to embed Gists, but here is the link to it .... 😥

Solution

Collapse
le_newtype profile image
Nicholas ―M―

Doing this taught me about Array.prototype.some. I originally wanted to use .forEach, but needed a way to break out of the loop once we found the dominator -- no need to keep processing once the answer has been found, especially if the scenario was an array of something ridiculous, like 15,000 items.