Skip to content

Instantly share code, notes, and snippets.

@NovoManu
Created March 13, 2021 14:46
Show Gist options
  • Save NovoManu/526cb0b92ce207b3c44c24d5f645fc1d to your computer and use it in GitHub Desktop.
Save NovoManu/526cb0b92ce207b3c44c24d5f645fc1d to your computer and use it in GitHub Desktop.
const promise = (duration = 0) => {
return new Promise((resolve, reject) => {
setTimeout(resolve, duration)
})
}
promise(1000)
.then(() => {
console.log('1 sec')
return promise(500)
})
.then(() => {
console.log('1.5 sec')
return promise(500)
})
.then(() => {
console.log('2 sec')
return promise(500)
})
.then(() => {
console.log('2.5 sec')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment