Question: - Callbacks, Promises, Async / Await Consider the following JS code that does not work as intended: / / The following code does not work.
Callbacks, Promises, AsyncAwait
Consider the following JS code that does not work as intended:
The following code does not work. Make it work with callbacks first. Then with
promises
function noAddGruntmsg
setTimeoutmsgreturn msg;;
function noAddSmackmsg
setTimeoutmsgreturnmsg;
function noAddBreathmsg
setTimeoutmsgreturnmsg;
let msg "telephone";
let modded noAddGruntmsg;
modded noAddSmackmodded;
modded noAddBreathmodded;
console.logmodded; expected outcome: telephone
Subtask A: Write a JSfile that fixes the above code using callbackfunctions, so that it logs to console
after seconds:
telephone
The calls must happen one after another, meaning that after second there exists an object named
msg with value telephone, after two seconds it becomes telephone and so
on
Subtask B: Do the same as in Subtask A but use Promises with thenchaining instead of Callbacks
Subtask C: Do the same as in Subtask A but use asyncawaitsyntax instead of then you can still use
then for the last Promise, if you need to
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
