I\'ve taken a look at a few questions on recursion in promises and am confused on how to implement them properly:
Many members already mentioned, need to resolve with the promise returned by the recursion.
I would like to share code into async/await syntax.
const printNumber = (i) => console.log("i is now: " + i);
// recursive function to call number increment order
const recursiveCallNumber = async (i, checkCondition) => {
// if false return it, other wise continue to next step
if (!checkCondition(i)) return;
// then print
printNumber(i);
// then call again for print next number
recursiveCallNumber(++i, checkCondition);
}
await recursiveCallNumber(1, (i) => i <= 10);