Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Creating a promise

JS
copy
let done = true

const isItDoneYet = new Promise((resolve, reject) => {
  if (done) {
    const workDone = 'Here is the thing I built'
    resolve(workDone)
  } else {
    const why = 'Still working on something else'
    reject(why)
  }
})
Source by nodejs.dev #
 
PREVIOUS NEXT
Tagged: #Creating #promise
ADD COMMENT
Topic
Name
6+9 =