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

Why are quotation marks (" ") required for the image when they're already in the photo?

photo: "img/golden.jpg"
src="${pet.photo}"

Thanks for responding. I guess I should've included my html variable:

`<h2>${pet.name}</h2> <img src="${pet.photo}" alt="${pet.breed}"> <h2>${pet.type}</h2> <p>${pet.breed}</p><h3>${pet.age}</h3>`

Okay got it. I guess there is no need of quote but having quote wrapped around ${pet.photo} is totally fine. You can remove that as well.

let a = `<h2>${pet.name}</h2> <img src=${pet.photo} alt=${pet.breed}> <h2>${pet.type}</h2> <p>${pet.breed}</p><h3>${pet.age}</h3>`

1 Answer

Hey Gary Angarita ,

The code should be like this

src=`${pet.photo}`

There is no need of quotation mark but you may need backtick for make template literal work.

Reference: (Template Literal)[https://css-tricks.com/template-literals/]