Build an fCC Forum Leaderboard - Build an fCC Forum Leaderboard

Tell us what’s happening:

My forumCategory function seems fine, test 17-18 request that forumCategory(200) should return general anchor while category with id 200 is not found in categories array, so i add it at the front of the list as you can see, now i passed test 17, but test 18 is still failed, where it say => forumCategory(200) should return a string containing an anchor element with href=“https://forum.freecodecamp.org/c/general/200

Your code so far

<!-- file: index.html -->

/* file: styles.css */

/* file: script.js */

Your browser information:

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

Challenge Information:

Build an fCC Forum Leaderboard - Build an fCC Forum Leaderboard

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/lab-fcc-forum-leaderboard/673c91f0b934834bc4a3ecc2.md at main · freeCodeCamp/freeCodeCamp · GitHub

Welcome to the forum @ukasyah.old,

Your code was too long to be automatically inserted by the help button.

Please update the message to include your code, formatted as follows:

When you enter a code, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

Happy coding

Tell us what’s happening:

11th users stories required for each img element to have alt attribute set to the value of name property of the poster, if we do it so it wont pass the test, i tried to change it to the value of name property of the user and it passed the test

Your code so far

<!-- file: index.html -->

/* file: styles.css */

/* file: script.js */
const forumLatest =
  'https://cdn.freecodecamp.org/curriculum/forum-latest/latest.json';
const forumTopicUrl = 'https://forum.freecodecamp.org/t/';
const forumCategoryUrl = 'https://forum.freecodecamp.org/c/';
const avatarUrl = 'https://cdn.freecodecamp.org/curriculum/forum-latest';

const allCategories = {
  299: { category: 'Career Advice', className: 'career' },
  409: { category: 'Project Feedback', className: 'feedback' },
  417: { category: 'freeCodeCamp Support', className: 'support' },
  421: { category: 'JavaScript', className: 'javascript' },
  423: { category: 'HTML - CSS', className: 'html-css' },
  424: { category: 'Python', className: 'python' },
  432: { category: 'You Can Do This!', className: 'motivation' },
  560: { category: 'Back-End Development', className: 'backend' }
};

function timeAgo(timeStamp) {
  const diff = Date.now() - new Date(timeStamp).getTime();

  const minute = 1000 * 60;
  const hour = minute * 60;
  const day = hour * 24;

  if(diff < hour) {
    return `${Math.floor(diff / minute)}m ago`
  }

  if(diff < day) {
    return `${Math.floor(diff / hour)}h ago`
  }

  return `${Math.floor(diff / day)}d ago`
  
}

function viewCount(number) {
  if(number >= 1000) {
    return `${Math.floor(number / 1000)}k`
  }

  return number
}

function forumCategory(categoryId) {
  const {category, className} = allCategories[categoryId] ?? {category: "General", className: "general"};

  return `<a class="category ${className}" href="${forumCategoryUrl}${className}/${categoryId}">${category}</a>`
}

function avatars(posters, users) {
  
  return posters.map((poster) => {
    const {avatar_template, name} = users.find((user) => user.id === poster.user_id);
    let avatarTemplate = avatar_template.replace("{size}", "30");

    if(avatarTemplate.startsWith("/")) {
      avatarTemplate = avatarUrl + avatarTemplate;
    }

    return `<img alt="${name}" src="${avatarTemplate}">`
  }).join("")
}

Your browser information:

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

Challenge Information:

Build an fCC Forum Leaderboard - Build an fCC Forum Leaderboard

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/lab-fcc-forum-leaderboard/673c91f0b934834bc4a3ecc2.md at main · freeCodeCamp/freeCodeCamp · GitHub

When I check your code, Tests #25-36 are failing, but it looks like you haven’t implemented the user stories associated with those tests.