// Ok, that's kinda neat. But why tho?
// Well, these promises work in parallel. Let's demonstrate this!
// This function resolves after a passed "timeout"
function slowPromise(identifier, timeout, result) {
return new Promise((resolve) => {
console.log(`Starting promise: ${identifier}`)
setTimeout(() => {console.log(`Ending promise: ${identifier}`); resolve(result)}, timeout)
})
}
// Here's what await does on its own - you'll see output one at a time. Start, End, Start, End.
let result1 = await slowPromise("1", 1000, 10);
let result2 = await slowPromise("2", 1000, 20);
result1 + result2