JS
copy
let done =trueconst isItDoneYet =newPromise((resolve, reject)=>{if(done){const workDone ='Here is the thing I built'resolve(workDone)}else{const why ='Still working on something else'reject(why)}})
const count =true;let countValue =newPromise(function(resolve, reject){if(count){resolve("There is a count value.");}else{reject("There is no count value");}});console.log(countValue);
let fetchSent =fetch("/test",{method:"POST",body:JSON.stringify({name:"NAME NAME NAME"}),headers:{'Content-type':'application/json; charset=UTF-8'}});const p1 =newPromise((resolve, reject)=>{resolve(fetchSent);// or// reject(new Error("Error!"));})return p1;/*console.log(p1) will yield the fetch promise that was sent to you*/