Async/Await Syntax
What does Math.min(1000 * Math.pow(2, i), 10000) accomplish in this pattern?
async function retryWithBackoff(operation, retries = 3) {
for (let i = 0; i <= retries; i++) {
try {
return await operation();
} catch (err) {
if (i === retries) throw err;
const waitTime = Math.min(1000 * Math.pow(2, i), 10000);
await new Promise(r => setTimeout(r, waitTime));
}
}
}