Although I know promises in JS, return a single object. This is just me playing around with it on my chrome inspector and wondering why it will only return the resolved value(Explanation needed)
const soccerPlayer = ["Messi", "Maradona", "Lebron", "Mane"];
const myPromise = new Promise(( resolve, reject) => {
soccerPlayer.forEach( element => {
if( element.startsWith("M")) {
resolve("Thats a soccer star");
} else {
reject("Not a soccer star");
}
})
});
myPromise
.then(res => console.log(res));
.catch(err => console.log(err));
This will only print "Thats a soccer star" although "Lebron" doesnt start with m and it should be rejected