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

Tell us what’s happening:

creating a simple set of conditions based on the amount of time passed. the test appears to be reporting that result is not as expected thou test outside of FFC behave as expected .

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

// 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

Open the console, when you run the tests at the bottom you should also see

[ReferenceError: minutes is not defined]

That is what is stopping your function from working, solve that error

oh man I do not believe I did this . I see the error of my ways

2 Likes

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