Quiz: Waiting for the Pizza

After a click, the page should show Your Funghi is ready!, but it shows [object Promise]. Click the line with the mistake in script.js.

// Pretends to be a pizzeria: returns a Promise
// that gets the finished pizza a second later.
function orderPizza(pizza) {
    return new Promise(function (resolve) {
        setTimeout(function () {
            resolve(`Your ${pizza} is ready!`);
        }, 1000);
    });
}

const orderButton = document.querySelector("#order");
const message = document.querySelector("#message");

orderButton.addEventListener("click", async function () {
    message.textContent = "Baking your pizza…";
    const pizza = orderPizza("Funghi");
    message.textContent = pizza;
});

Start programming for free

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

Or sign up with:

Back

6/9

Next