Tell us what’s happening:
I have everything passing except the two test at “/api/exercise/log”, which I don’t understand because my return looks identical to the examples as for as I can tell.
What am I missing?
Here’s a link to all my replit code:
https://replit.com/@dletulle/boilerplate-project-exercisetracker
Your project link(s)
solution: https://boilerplate-project-exercisetracker.dletulle.repl.co
app.get("/api/exercise/log", (req, res) => {
User.findById(req.query.userId, (err, user) => {
if (err) return res.send(err.message);
if (user === null) return res.send("Unknown userId");
if (err) return res.send(err.message);
let froom;
let to;
req.query.to ? to = new Date(req.query.to).getTime()
: to = new Date(8640000000000000).getTime();
req.query.from ? froom = new Date(req.query.from).getTime()
: froom = new Date(0).getTime();
const newLog = user.log.filter((arr) => {
const currentDate = new Date(arr.date).getTime();
return currentDate >= froom && currentDate <= to})
let limit = parseInt(req.query.limit);
!limit ? limit = newLog.length
: "";
res.json({ _id: user.id, username: user.username, count: user.count, log: newLog.slice(0, limit)})
})
})
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36.
Challenge: Exercise Tracker
Link to the challenge:





Thanks again!