Issue
I need to sort an array having date and month as input.
ex: date = ["01-jun","2-may","23-apr","10-dec"];
Solution
You can try it :
let date = ["01-jun","2-may","23-apr","10-dec"]
date.sort((a, b) => {
let dateA = new Date(a)
let dateB = new Date(b)
return dateA - dateB
})
console.log(date)
Answered By - Xupitan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.