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 don't you put ; after then() ?

here:

function fetchData(url) { return fetch(url) .then(res => res.json()) }

and here:

function fetchBreedImage() { const breed = select.value; const img = card.querySelector('img'); const p = card.querySelector('p');

fetchData(https://dog.ceo/api/breed/${breed}/images/random) .then(data => { img.src = data.message; img.alt = breed; p.textContent = Click to view more ${breed}s }) }

2 Answers

Steven Parker
Steven Parker
231,172 Points

Semicolons are optional at the end of statements, so they were probably just overlooked by the instructor and QA folks.

But they are a "best practice", so good eye! :+1:

Hey! in JavaScript there is some thing called Automatic Semicolon Insertion (ASI) which is in certain situations a semicolon will be automatically inserted by JavaScript engine.

Click here to get more information about ASI

Steven Parker
Steven Parker
231,172 Points

If you read the rules for ASI you'll notice that none of them apply here. And relying on ASI would also not be "best practice".