Get closest number of array
<p>I want get closest number in the array. It have to be like this:
<br />
For example I have an array: <code>[1, 3, 7, 15, 40, 55, 70, 80, 95]</code>
<br /></p>

<p>Number variable: <code>numberD1</code>;
<br />
If numberD1: 8 - The closest number can be only 7. Not 15.
<br />
If numberD1: 54 - It can be only 40. Not 55.
<br /></p>

<p>I mean, i want closest number like this. But what I selected the number mustn't be higher than the closest number(like <code>Math.floor()</code> function).</p>

<p>Sorry for my Bad English. I hope i told my problem as good.</p>