0
return `${date.getDate()} ${monthsNames[date.getMonth() - 1]}`;
This code gives an "illegal return statement"....please help. the code is in javascript
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]}`;
}
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.
0
Gaurav,
Did you solve it bro?