Hi everyone, I've encountered an issue with a JavaScript promise question that's throwing errors
function delay(n) {
return new Promise((resolve) => setTimeout(resolve, n*1000));
}
The expected output should be "It is now 2 seconds later" and then "It is now 1.5 seconds later" but instead, it displays:
It is now undefined later
It is now undefined later
delay(2)
.then(seconds => console.log(`It is now ${seconds} later`))
.then(()=> delay(1.5))
.then(seconds => console.log(`It is now ${seconds} later`));