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

Tell us what’s happening:

I understand what they are asking me to do. my question is why is it category_id and why not category.id ?? like we usually use?

why are we using underscore instead of dot notation?
what is this underscore?
if anyone could enlighten me about it . It would be appreciated.

Your code so far

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

/* file: styles.css */

/* file: script.js */

const showLatestPosts = (data) => {
  const { topic_list, users } = data;
  const { topics } = topic_list;

  postsContainer.innerHTML = topics.map((item) => {
    const {
      id,
      title,
      views,
      posts_count,
      slug,
      posters,
      category_id,
      bumped_at,
    } = item;

    return `
    <tr>
      <td>
        <p class="post-title">${title}</p>

// User Editable Region

        ${forumCategory(category_id)}

// User Editable Region

      </td>
      <td></td>
      <td>${posts_count - 1}</td>
      <td>${viewCount(views)}</td>
      <td>${timeAgo(bumped_at)}</td>
    </tr>`;
  }).join("");
};

Your browser information:

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

Challenge Information:

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

That category_id is just number, it’s not an object which would have id property.

Why isn’t it an actual category object? That would make storing it take up more space than using just id, which can point to actual category.

1 Like

They used id as a parameter in one of the other functions but usually this is an attribute in HTML. Here it’s a property in the data object and its being destructured to a value.

1 Like

that made sense. thank you so much :smile:

1 Like