Given the code, when will line 4 be evaluated, and what would the affirmation variable be at that point in the code?
function setMessage(affirmation, delay) {
return new Promise((resolve, reject) => {
setTimeout(() => {
console.log(affirmation)
// line 4 - what would `affirmation` be?
resolve();
}, delay);
});
}
setMessage("You're doing great!", 500)
.then(() => setMessage("Keep up the great work!", 3000));
Given the above code, when will line 4 be evaluated, and what would the affirmation variable be at that point in the code?
A. Line 4 will be evaluated almost immediately, and affirmation will be "You're doing great!". Almost immediately after that, Line 4 will be evaluated again, and affirmation will be "Keep up the great work!"
B. Line 4 will be evaluated almost immediately, and affirmation will be "You're doing great!". After a half-second delay, line 4 will be evaluated again, and affirmation will be "Keep up the great work!"
C. Line 4 will be evaluated almost immediately, and affirmation will be "You're doing great!". After a three and a half-second delay, line 4 will be evaluated again, and affirmation will be "Keep up the great work!"
D. Line 4 will be evaluated after a half-second delay, and affirmation will be "You're doing great!". After another three-second delay, line 4 will be evaluated again, and affirmation will be "Keep up the great work!".