Tell us what’s happening:
Hello, I need some help with my avatars function here.
The instructions are to include the poster name as an alt text on the image however the objects in the posters array do not have a name property I can see extras, description, user_id, primary_group_id, and flair_group_id. I have already tried replacing with the name from the users object
22. Each img element in the string returned by the avatars function should have an alt text with the value of the name property of the poster
Your code so far
function avatars(posters, users) {
console.log(posters)
return posters
.map((poster) => {
const user = users.find((user) => user.id === poster.user_id);
if (user) {
let src = user.avatar_template.replace("{size}", "30");
if (!src.startsWith("http")) {
src = `${avatarUrl}/${src}`;
}
// return `<img src="${src}" alt="${user.name}" />` ; This works but still fails the test
return `<img src="${src}" alt="${poster.name}" />`;//this does not work at all
}
return '';
})
.join('');
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
Challenge Information:
Build an fCC Forum Leaderboard - Build an fCC Forum Leaderboard