let promiseToClean = new Promise(function( resolve, reject) {
// cleaning the room
let isClean = false;
if (isClean){
resolve('Clean');
} else {
reject('not Clean');
}
})
The Caller:
promiseToClean.then(function() {
console.log('the room is clean')
}).catch(function() {
console.log('the room is not clean')
})