Question from the Javascript - Fundamentals test

Write a JavaScript function that fetches data from an API and logs it to the console.

Medium

What is the output of the following JavaScript code?

function fetchData() {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      resolve("Data fetched!");
    }, 1000);
  });
}

async function displayData() {
  const data = await fetchData();
  console.log(data);
}

displayData();
console.log("After displayData call");
Author: Vincent CotroStatus: PublishedQuestion passed 1614 times
Edit
15
Community Evaluations
developer avatar
Turing spirituel
20/08/2023
Concerne l'ordre de priorité d'exécution dans JavaScript, c'est important.
developer avatar
KOUAME PAUL ARNAUD
19/12/2023
la question peut prĂȘtĂ© a confusion , car il ya un setTimeout donc la reponse sera retardĂ©