function maxDate(dates) {
let max = dates[0],
obj = new Date(dates[0]);
dates.forEach(function(dt) {
if (new Date( dt ) > obj) {
max = dt;
obj = new Date(dt);
}
});
return max;
}
const dates = ['2022/03/20', '2022/05/21', '2022/01/13', '2022/01/14', '2022/05/20'];
console.log(maxDate(dates));
/*
run:
2022/05/21
*/