JSFiddle - React, Tailwind, and code Playground

JavaScript

let isMomHappy = true

let willIGetNewPhone = new Promise(function (resolve, reject) {
	if (isMomHappy) {
  	let phone = {
    	brand: 'Samsung',
      color: 'black',
      type: 's8'
    }
    resolve(phone)
  } else {
  	let reason = new Error('Mom is unhappy')
  	reject(reason)
  }
})

function askMom () {
	willIGetNewPhone.then(function (fulfilled) {
  	console.log(fulfilled)
  }).catch(function (error) {
  	console.log(error)
  })
}

askMom()