Actually, you don't need to return a promise on the addNumber function. Not explicitly at least.
If you declare it as an async function, its return will automatically be wrapped into a promise resolution. If you throw an exception, it will be the rejection for said function.
To summarize, an async function will run as a microtask, working as a promise.
I think you already knew that, just don't wanna let that go unoticed.
Actually, you don't need to return a promise on the addNumber function. Not explicitly at least.
If you declare it as an async function, its return will automatically be wrapped into a promise resolution. If you throw an exception, it will be the rejection for said function.
To summarize, an async function will run as a microtask, working as a promise.
I think you already knew that, just don't wanna let that go unoticed.
Thanks for sharing this. It's a wonderful insight.