function filterBooksPromise(colorful, amountOfPage){
return new Promise(function(resolve, reject){
var books=[
{name: "shinchan", totalPage: 50, isColorful: true},
{name: "Kalkulus", totalPage: 250, isColorful: false},
{name: "doraemon", totalPage: 40, isColorful: true},
{name: "algoritma", totalPage: 250, isColorful: false},
]
if (amountOfPage >= 40) {
resolve(books.filter(x=> x.totalPage >= amountOfPage && x.isColorful == colorful));
} else {
var reason= "Sorry, books under 40 pages are not available"
reject(reason);
}
});
}
Condition, input 2 arguments into the parameter of the promise function with the following conditions: the book is in color and the number of pages is 40,the book is colorless and the number of pages is 250, and book is in color and the number of pages is 30.