Quiz: Where Are the Animals?

The page should list the shelter's animals, but the list stays empty, and the console says TypeError: animals is not iterable. Click the line with the mistake in script.js.

const animalList = document.querySelector("#animals");

async function loadAnimals() {
    const response = await fetch("animals.json");
    const animals = response.json();
    for (const animal of animals) {
        const item = document.createElement("li");
        item.textContent = animal.name;
        animalList.append(item);
    }
}

loadAnimals();

Start programming for free

By signing up, you agree to the Terms of Service and Privacy Policy.

Or sign up with:

Back

4/9

Next