 <p>Lots of ways to go about this! This is another Vanilla Javascript one, fill free to mix and match according to your actual specs.</p> <pre><code>var fruits = [{ fruit: "apple", selected: false }, { fruit: "pear", selected: false }, { fruit: "orange", selected: false }, { fruit: "pineaple", selected: false }, { fruit: "mango", selected: true }, { fruit: "peach", selected: false }, { fruit: "strawberry", selected: false }]; var selectedFruits = fruits.reduce((result, el) =&gt; { if(el.selected) { return Array(el).concat(result).slice(0, 3); } if (result.length &gt; 2) return result; result.push(el); return result; }, Array()); console.log(selectedFruits); </code></pre>