Dates list:
const datesToBeChecked = [ '2020-07-06', '2020-07-13', '2020-07-20' ]
Date to be checked for
const dateToCheckFor = '2020-07-07';
How can I get the nearest date for the date in the dates array using moment.js?
I want the function to return 2020-07-13 in this case.
I found a couple of answers online but none of them use YYYY-MM-DD format neither moment.js. I want to use moment.js to achieve this, thanks!