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 trial

JavaScript Displaying the Content

Homero Mendoza
Homero Mendoza
12,782 Points

Select.value is not displaying on the function generateImage

for some reason when displayed on the page the select.value doesnt display its just empty. someone know why?

const select = document.getElementById('breeds'); const card = document.querySelector('.card'); const form = document.querySelector('form');

// ------------------------------------------ // FETCH FUNCTIONS // ------------------------------------------ //fetch the img api fetch('https://dog.ceo/api/breeds/image/random') .then(response => response.json()) .then(data => generateImage(data.message))

//fetch the dog names fetch('https://dog.ceo/api/breeds/list') .then(response => response.json()) .then(data => generateOptions(data.message))

// ------------------------------------------ // HELPER FUNCTIONS // ------------------------------------------ function generateOptions(data){ const options = data.map(item => <option value ='${item}'>${item}</option> ); select.innerHTML = options; }

function generateImage(data){ const html= <img src ='${data}' alt> <p>Click to view images of ${select.value}s</p> ; card.innerHTML = html; }

// --------------------------

1 Answer

Steven Parker
Steven Parker
231,248 Points

The select list appears populated for me, but then I had to make a few assumptions about the code since it wasn't formatted for display.

When posting code, always use Markdown formatting to preserve the code's appearance and retain special symbols. An even better way to share code and make your issue easy to replicate is to make a snapshot of your workspace and post the link to it here.

how do you post a pic to these threads. I have a question about this video and I took a screen shot , but I don't know how to add it to my post.

Steven Parker
Steven Parker
231,248 Points

A "snapshot" (use link in the answer for a video) is usually way more helpful than a screenshot, as it allows the entire environment to replicated.

If you must post an image, first it needs to be hosted somewhere and then you can link to it in your question. Also, be sure to create a new question and don't post one as an "answer" to an existing one.