I have a number from minus 1000 to plus 1000 and I have an array with numbers in it. Like this:

[2, 42, 82, 122, 162, 202, 242, 282, 322, 362]

I want that the number I’ve got changes to the nearest number of the array.

For example I get 80 as number I want it to get 82.

22 Answers
22

Leave a Reply

Your email address will not be published. Required fields are marked *