title: Get Find ID connected with range of numbers by some number. Better way?
body: <p>I'm saving ID's to object under key what representing range of numbers. ID is valid for given range:</p>
  
  <pre><code>let ranges = {
    "1-100": 102,
    "101-698": 47,
    "699-748": 999,
    ...
  }
  </code></pre>
  
  <p>As input I give you number and I need ID (<code>Example: num 50 = ID 102, num 500 = ID 47</code>). Doing this by:</p>
  
  <pre><code>let keys = Object.keys(ranges);
  let ID;
  for (let i = 0, len = keys.length; i &lt; len; i++) {
      let range = keys[i].split("-");
      if (winningTicket &gt;= range[0] &amp;&amp; winningTicket &lt;= range[1]) {
          ID = ranges[keys[i]];
          break;
      }
  }
  </code></pre>
  
  <p>Is there better way? I think this is very dumb algorithm and saving mechanism...</p>