Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialGary Pintado
4,761 PointsMade my solution work, but noticed when inspecting in chrome browser the alt text did not update like the rest.
const pets = [
{
name: 'Joey',
type: 'Dog',
breed: 'Australian Shepherd',
age: 8,
photo: 'img/aussie.jpg'
},
{
name: 'Patches',
type: 'Cat',
breed: 'Domestic Shorthair',
age: 1,
photo: 'img/tabby.jpg'
},
{
name: 'Pugsley',
type: 'Dog',
breed: 'Pug',
age: 6,
photo: 'img/pug.jpg'
},
{
name: 'Simba',
type: 'Cat',
breed: 'Persian',
age: 5,
photo: 'img/persian.jpg'
},
]
let html = '';
for (let i =0; i < Object.keys(pets).length; i++) {
html += `
<h2> ${pets[i].name} </h2>
<h3>${pets[i].type} | ${pets[i].breed}</h3>
<p>Age: ${pets[i].age}</p>
<img src=${pets[i].photo} alt=${pets[i].breed}>
`;
}
document.querySelector('main').innerHTML = html;
1 Answer
Tom Phillips
897 PointsYou forgot to put quotation marks around your alt string. :-) If you do this you're golden.
<img src=${pets[i].photo} alt="${pets[i].breed}">