Closest value from number in array. Find So Flag Rank.

Closest value from number in array. Find So Flag Rank.

by Shree Khanal

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>

JavaScript

//4733879, "Call me flaggy", "4733879 is Filnor's user id"
let flagRank = [
  [365, 'A flag a day keeps bad posts away', 'One year has 365 days'],
  [811, 'How thare thy?', 'I think you know whose user id that is'],
  [1111, 'No badge needed', 'A number is prettier than a badge anyway!'],
  [1337, 'l337 fl4663r', '[l337 5p34k 15 4w350m3!](https://en.wikipedia.org/wiki/Leet)'],
  [1969, 'Moon landing', 'I flagged the moon!'],
  [2008, 'Flag Overflow', 'Stack Overflow was created in 2008'],
  [2395, 'Flag me up, Scotty', '[We don\'t beam, we flag](https://en.wikipedia.org/wiki/Beam_me_up,_Scotty)'],
  [3456, '<3456', 'You <3 flagging too much'],
  [5566, '[Long Time No Flag](https://en.wikipedia.org/wiki/Long_Time_No_See_(5566_album))', '[Taiwanese boy band, formed under Taiwanese music company, J-Star](https://en.wikipedia.org/wiki/5566)'],
  [10000, 'Elite Squad', '[At one point of time, there were only 16 of us](https://chat.meta.stackexchange.com/transcript/message/6083409#6083409)'],
  [19679, 'Professional Larnsonist', '19679 is Brad Larnson\'s user id'],
  [22656, 'Almost Jon Skeet', '22656 is his (John\'s) user ID'],
  [33333, 'The Mad Flagger', 'Got nothing better to do with your time? ;D'],
  [42195, 'The Marathon', 'Marathon\'s length in meters'],
  [65536, 'The two to the sixteen', ''],
  [101010, "Definitely a robot", "42 in binary code. [Also 42 is the Answer to the Ultimate Question of Life, the Universe, and Everything](https://en.wikipedia.org/wiki/Phrases_from_The_Hitchhiker%27s_Guide_to_the_Galaxy#Answer_to_the_Ultimate_Question_of_Life,_the_Universe,_and_Everything_(42))"],
  [314159, '\u03C0', 'Who ate all the Pi?'],
  [874188, 'tripleee', 'Wheeereee has theee eee goneee?'],
  [4294967296, 'A `long` journey', '']
]

var getRank = [];
var $result = '78 helpful flags';
var goal = $result.trim().split(' ')[0].replace(/,/g, '');
//var goal = 5000;
$.each(flagRank, function(index, item) {
  getRank.push(flagRank[index][0])
});


var closest =...