Error test #15 in Exercise Tracker

Tell us what’s happening:
Describe your issue in detail here.

Hi, need help with the test #15.

" The date property of any object in the log array that is returned from GET /api/users/:id/logs should be a string… Use the dateString format of the Date API."

I don’t know, but the response object seems right, but the test still doesn’t pass.

Your code so far

My replit with the code:

https://replit.com/@willian-pessoa/boilerplate-project-exercisetracker?v=1

here is the code when a create the response object, I’m using the toDateString how suggest in the test, but it’s not working.

responseObject = {};
responseObject[’_id’] = result.id;
responseObject[‘username’] = result.username;
responseObject[‘count’] = result.log.length;
let arrLog = result.log.map(
function(item){
return{
description: item.description,
duration: item.duration,
date: new Date(item.date).toDateString()
}
})
responseObject[“log”] = arrLog;
console.log(responseObject);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36

Challenge: Exercise Tracker

Link to the challenge:

I figure out, some tests input was going with the string “Invalid Date”. So I fix that using the current time to display, now the test pass.

1 Like

Nice one used the same method and I was able to pass the test, after battling with it for days. Thanks for sharing