Build an fCC Forum Leaderboard - Build an fCC Forum Leaderboard

Tell us what’s happening:

What;s wrong with this function?

function avatars(posters, users) {
  return users
    .map((user) => {
      const poster = posters.find((p) => p.user_id === user.id);
      if (!poster || !poster.avatar_template || !poster.name) {
        return '';
      }

      let src = poster.avatar_template.replace('{size}', '30');
      if (!src.startsWith('http')) {
        src = `${avatarUrl}/${src}`;
      }

      return `<img src="${src}" alt="${poster.name}" />`;
    })
    .join('');
}

Your code so far

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

/* file: styles.css */

/* file: script.js */

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.6 Safari/605.1.15

Challenge Information:

Build an fCC Forum Leaderboard - Build an fCC Forum Leaderboard

I’ve edited your post to improve the readability of the code. When you enter a code block into a forum post, 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 (').

Doesn’t the challenge give you any feedback?

Also please share all your code to help us test it in context.

It depends what you want it to do. Can you try explaining what you are trying to achieve?

Try to phrase your question as a collaboration with humans and not a demand to AI.

Provide context and errors you have encountered. Share your thought process and what troubleshooting steps you’ve taken.