How to find a same or nearest higher number from a specific set of numbers :javascript

后端 未结 1 1695
孤独总比滥情好
孤独总比滥情好 2021-01-28 07:47

I have a set of numbers & my requirements is to find same or nearest higher number to a specific variable set/object of numbers

var person = {
    A:107,
            


        
相关标签:
1条回答
  • 2021-01-28 08:09

    You just need to change your line

    if (d > 0 && d < diff) {
    

    to

    if (d >= 0 && d < diff) {
    

    so it includes the numbers that are equal as well.

    0 讨论(0)
提交回复
热议问题