const myfunc = (add1, add2) => { return new Promise((resolve, reject) => { const new_value = add1 + add2; setTimeout(() => { resolve(new_value); }, 3000); }) }; myfunc(1, 5) .then((added_value) => { console.log(`the value is ${added_value}`); }) .catch((err) => { console.error(`there was an error ${err}`); }); //------------------------------- const myfunc = (add1, add2) => { return new Promise((resolve, reject) => { const new_value = add1 + add2; setTimeout(() => { console.log(`new value ${new_value}`); resolve(new_value); }, 3000); }) }; const mypromises = [ myfunc(1, 5), myfunc(6, 5), myfunc(2, 9), myfunc(10, 5), ]; Promise.all(mypromises) .then(() => { console.log('they all resolved'); });