0

Help me resolve the below code showing syntax error. I know there is definitely some problem. How to write the below checkInventory order with the help of arrow functions.

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;
};
Ravi
  • 30,808
  • 18
  • 108
  • 168
Shivangi
  • 31
  • 5
  • 2
    You might consider using consistent indentation when writing code - it'll make reading and debugging it much easier, not only for potential answerers, but for you as well, when we can all see the `{` `}` blocks and their nesting level at a glance, rather than having to carefully pick through each line just to pick up on the logical paths. – CertainPerformance Feb 15 '19 at 09:44
  • 1
    `checkInventory(order) = ` You can only assign to variable names – CertainPerformance Feb 15 '19 at 09:44
  • what is this syntax `new Promise(resolvedValue, rejectReason){}`? – madalinivascu Feb 15 '19 at 09:53

1 Answers1

0

That code is part of a tutorial from codecademy whereby the checkInventory() returns a promise and a .then() is attached to it and the two handlers i.e handleSuccess() and handleFailure() are passed as arguments. Therefore the code will look like this:

checkInventory(order).then(handleSuccess, handleFailure);
maksbd19
  • 3,467
  • 23
  • 37
Gwamaka Charles
  • 469
  • 4
  • 5