title: How to get index of the array item with nearest value?
body: <p>I have following array of the objects in json and i would like to get index of the object in array which is nearest by count of days attribute opposite the given number value. </p>
  
  <p>Exist any built-in function in jQuery or JS for this, or how can i easily solve it please?</p>
  
  <p>Thanks for any help. </p>
  
  <pre><code>"warningAttributes": [
                          {
                              "id": "3",
                              "days": 15,                          
                              "color": "#FFFFFF"                 
                          },
                          {
                              "id": "4",
                              "days": 98,                          
                              "color": "#343434"                  
                          }
                      ]
  </code></pre>