帮助我解决以下代码显示语法错误。我知道肯定有一些问题。如何在箭头功能的帮助下编写以下checkInventory订单。
const {checkInventory} = require('./library.js');
const order = [['sunglasses', 0], ['bags', 2]];
const handleSuccess = (resolvedValue) => {
console.log(resolvedValue);
};
const handleFailure = (rejectReason) => {
console.log(rejectReason);
};
checkInventory(order)=new Promise(resolvedValue, rejectReason){
if(resolvedValue)
return handleSuccess;
else
return handleFailure;
};
该代码是Codecademy教程的一部分checkInventory()
返回承诺,并附加了.then()
并且两个处理程序即handleSuccess()
和handleFailure()
作为参数传递。因此,代码看起来像这样:
checkInventory(order).then(handleSuccess, handleFailure);