0

帮我解决以下显示语法错误的代码。我知道肯定有问题。如何借助箭头函数编写以下 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;
};
4

1 回答 1

0

该代码是codecademy教程的一部分, 其中checkInventory()返回一个 promise 和 a.then()附加到它,两个处理程序 iehandleSuccess()handleFailure()作为参数传递。因此代码将如下所示:

checkInventory(order).then(handleSuccess, handleFailure);
于 2019-08-20T06:36:29.280 回答