title: JS - Apply limit on array of object
body: <p>i have a simple array of object in js</p>
  <pre><code>const users = [
     {categories: 'FRENCH', user: [{id: 1}, {id: 2}]}, 
     {categories: 'BELGIUM', user: [{id: 5}, {id: 3}, {id:4}]},
     {categories: 'USA', user: [{id: 12}, {id: 13}, {id:15}]}  
  ]
  </code></pre>
  <p>I want to limit this array depending on user size
  So for example if i want <code>only 3 user</code> a function name <code>limitTo(users, 3)</code> should return :</p>
  <pre><code>const only3users = [
     {categories: 'FRENCH', user: [{id: 1}, {id: 2}]}, 
     {categories: 'BELGIUM', user: [{id: 5}]}, 
  ]
  </code></pre>
  <p>What's the best algorithm to achieve this ?</p>
  <p>Thanks</p>