function stepPromise(stepName) { return new Promise((resolve) => { setTimeout(() => { console.log(`${stepName} completed`); resolve(); }, 1000); }); } // Promise chaining to avoid callback hell stepPromise("Step 1") .then(() => stepPromise("Step 2")) .then(() => stepPromise("Step 3")) .then(() => console.log("All steps completed (with Promise)"));