Question d’entretien chez Amazon

Write a function with Async and Await.

Réponse à la question d'entretien

Utilisateur anonyme

6 juil. 2021

//Call timer function that return result after 3 seconds countTimer() { return new Promise( (resolve) => { setTimeout( () => { resolve('The time is up!'); }, 3000 ); }) }; //Start Timer async startTimer(){ console.log('Timer activated'); const result = await countTimer(); console.log('result'); }; startTimer();

1