Promises have two parameters, one for success (resolve) and one for failure (reject). Each has a condition that must be satisfied in order for the Promise to be resolved – otherwise, it will be rejected:

PHOTO EMBED

Mon Aug 15 2022 20:12:37 GMT+0000 (Coordinated Universal Time)

Saved by @EMR4HKLMN #javascript

const promise = new Promise((resolve, reject) => {  
    let condition;
    
    if(condition is met) {    
        resolve('Promise is resolved successfully.');  
    } else {    
        reject('Promise is rejected');  
    }
});
content_copyCOPY

https://www.freecodecamp.org/news/top-javascript-concepts-to-know-before-learning-react/