Skip to content

Instantly share code, notes, and snippets.

View PH4N70M-0P5's full-sized avatar

Dimitry Robertson PH4N70M-0P5

  • Quiet Logistics
  • Hazelwood
View GitHub Profile
//first we define our new function as async and give it a name of f, with no arguments... or data between ()
async function f() {
//we make some data that will run normally
let result = 'first!';
//we make a new promise that takes 2 arguments, resolve, reject
let promise = new Promise((resolve, reject) => {
//we set a timeout so that out promise takes 1 second before it is finished
//when it is done, we resolve it with the messsage done!
setTimeout(() => resolve('done!'), 1000);
});
//the variable myNewPromise is a function that takes
//2 arguments, isResolved and IsNotResolved
const myNewPromise = new Promise((isResolved, isNotResolved)=>{
// we create a new variable isThePromiseResolved
//set it to true because we want it to be resolved.. right now
let isThePromiseResolved = true;
//what the if statment is saying is,
//if (isThePromiseResolved) is true (which it is)
if(isThePromiseResolved){
//then we execute isResolved!