Tell us what’s happening:
it says you should return string “1h ago” and I couldn’t figure out the problem ,please help me!
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
const timeAgo = (time) => {
const currentTime = new Date();
const lastPost = new Date(time);
const min = Math.floor((currentTime - lastPost) / 60000);
const h = Math.floor((currentTime - lastPost) / 3600000);
const d = Math.floor((currentTime - lastPost) / 86400000);
if(min < 60000){return `${min}m ago`;}
else if(h < 3600000 && h > 60000){return `${h}h ago`;}
else{return `${d}d ago`}
};
// User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
Challenge Information:
Learn Asynchronous Programming by Building an fCC Forum Leaderboard - Step 23