Frage im Vorstellungsgespräch bei Amazon

Write a function with Async and Await.

Antwort im Vorstellungsgespräch

Anonym

6. Juli 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