1
var reformatDate = function (date) {
2
const ans = [];
3
const month = [
4
"Jan",
5
"Feb",
6
"Mar",
7
"Apr",
8
"May",
9
"Jun",
10
"Jul",
11
"Aug",
12
"Sep",
13
"Oct",
14
"Nov",
15
"Dec",
16
];
17

18
const [inputDate, inputMonth, inputYear] = date.split(" ");
19
ans.push(inputYear);
20
ans.push("-");
21

22
const monthIndex = month.findIndex((mon) => mon === inputMonth);
23
const formatedMonth = String(monthIndex + 1).padStart(2, "0");
24
ans.push(formatedMonth);
25
ans.push("-");
26

27
const slicedDate = inputDate.slice(0, 2);
28
if (+slicedDate >= 10) {
29
ans.push(slicedDate);
30
} else {
31
const formatedDate = inputDate.slice(0, 1).padStart(2, "0");
32
ans.push(formatedDate);
33
}
34

35
return ans.join("");
36
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0