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 trialSarah Yasi
7,860 PointsNot displaying anything
There are no errors in the console, and the HTML is not showing in the elements tab. Is this a problem with the loop or with sending the information to HTML?
const main = document.querySelector('main'); let HTML = '';
for (let i = 0; i < pets.length; i++) {
let pet = pets[i];
html +=
<h2>${pet.name}</h2>
<h3${pet.type} | ${pet.breed}></h3>
<p>Age: ${pet.age}</p>
<img src="${pet.photo}" alt="${pet.breed}">
;
}
main.insertAdjacentHTML('beforeend', html);
2 Answers
Nikos Papapetrou
6,305 PointsI think you have forgotten the backticks. Example:
`${some.name}`
Also JavaScript is case sensitivity. HTML all caps different than html small caps. I think inside the code block you reassign the value.
Also here: https://teamtreehouse.com/community/posting-code-to-the-forum
how to post code in teamtreehouse to format your code and can easily someone understnad more easily.
Steven Parker
231,275 PointsI see two issues:
- "HTML" (all caps) is defined, but then "html" (lower case) is referenced in later code
- the "pets" array is not defined but referenced in the code
And to make your code display as intended (preserving indentation, line breaks, and special characters like backticks), always use Markdown formatting when posting.