title: Compare key and get neatest min key and it's value in JavaScript array of object
body: <p>I have JS object like this</p>
  <pre><code>    {
          &quot;100&quot;: {.. data },
          &quot;200&quot;: {.. data },
          &quot;500&quot;: {.. data },
          &quot;1000&quot;: {.. data }
          /* so on */
      }
  </code></pre>
  <p>How to search key with any number like</p>
  <ul>
  <li>if search number is between 0 to 99 then it will return false,</li>
  <li>if search number is between 100 to 199 then it will return key 100 and its value</li>
  <li>if 500 to 999 then return key 500 and its value</li>
  <li>if 1000+ then key as 1000 and its value</li>
  </ul>
  <p>here is my code</p>
  <pre><code>function find(num, obj) 
  {
    let keys = Object.keys(obj);
    
    result = keys.concat(Number.MAX_SAFE_INTEGER).filter(key =&gt; {
       return num &lt;= key;
    }).shift();
  
    if(result === Number.MAX_SAFE_INTEGER) {
       result = keys.pop();
    }
    return result;
  }
  
  
  console.log( find(125, data) )
  </code></pre>
  <p>it's returning 200 instead of 100</p>