0

return `${date.getDate()} ${monthsNames[date.getMonth() - 1]}`;

This code gives an "illegal return statement"....please help. the code is in javascript

15th Aug 2021, 4:35 PM
Gaurav 20
Gaurav 20 - avatar
3 Respostas
+ 1
hey Ipang ! I already used let date = new Date(dateString); my code is here.. formatedDates(dateString) { let date = new Date(dateString); return `${date.getDate()} ${monthsNames[date.getMonth() - 1]}`; }
15th Aug 2021, 6:26 PM
Gaurav 20
Gaurav 20 - avatar
0
You need a `Date` object where `getDate()` and `getMonth()` method were defined. const dobj = new Date(); return `${dobj.getDate()} ${monthsNames[dobj.getMonth() - 1]}`; This assumes you were writing the body of a function, and that the `monthsNames` are already defined somewhere.
15th Aug 2021, 4:49 PM
Ipang
0
Gaurav, Did you solve it bro?
16th Aug 2021, 12:22 AM
Ipang