title: How to reduce consecutive integers in an array to hyphenated range expressions?
body: <p>In JavaScript, how can I convert a sequence of numbers in an array to a range of numbers?  In other words, I want to express consecutive occurring integers (no gaps) as hyphenated ranges.</p>
  
  <p><code>[2,3,4,5,10,18,19,20]</code> would become <code>[2-5,10,18-20]</code></p>
  
  <p><code>[1,6,7,9,10,12]</code> would become <code>[1,6-7,9-10,12]</code></p>
  
  <p><code>[3,5,99]</code> would remain <code>[3,5,99]</code></p>
  
  <p><code>[5,6,7,8,9,10,11]</code> would become <code>[5-11]</code></p>