title: Remove value from array if it repeats x times | JavaScript
body: <p>I have an array with values and I am wondering what would be the best approach to reduce it if value repeat for example 3 or 4 times?</p>
  <p>I know how to remove duplicates, but what if I want the value to be repeated two times?</p>
  <p>Let's have for example this:</p>
  <pre><code>let arr = [1,1,1,3,3,2,4,4,7,7,7,7]
  let n = 2 //so I want numbers to repeat maximum two times
  </code></pre>
  <p>Result would be:</p>
  <pre><code>[1,1,3,3,2,4,4,7,7]
  </code></pre>