Learn Asynchronous Programming by Building an fCC Forum Leaderboard - Step 23

Tell us what’s happening:

This seems like it should work without issue, but its saying it is not able to return the string “30m ago” when 30 minutes have passed and I am not sure how to test the issue other than to add the console.logs that have already been added. Any advice?

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 minutes = Math.floor((currentTime - lastPost) / 60000);
  const hours = Math.floor((currentTime - lastPost) / 3600000);
  const days = Math.floor((currentTime - lastPost) / 86400000);

  if (minutes > 60) {
    return `${minutes}m ago`;
  } else if (hours > 24) {
    return `${hours}h ago`;
  } else if (days > 30) {
    return `${days}d ago`;
  }

  console.log()
  console.log(currentTime)
  console.log(lastPost)
  console.log(minutes)
  console.log(hours)
  console.log(days)

};

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64; rv:127.0) Gecko/20100101 Firefox/127.0

Challenge Information:

Learn Asynchronous Programming by Building an fCC Forum Leaderboard - Step 23

Hi there!
You used more than operator within the conditios, instead of less than operator. Read the instructions carefully.
@Sprigazalea

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.