Answer to Question #242932 in HTML/JavaScript Web Application for reddy

Question #242932

Given an array

mart of objects in the prefilled code and categoryOfItem, item as inputs, create a JS promise, resolve with "Item Found" text, if the

categoryOfItem matches with the category and the corresponding items list includes the itemreject with "Category Not Found" text, if the

categoryOfItem does not match with any category in the martreject with "Item Not Found" text, if the

items list does not include itemUse async/await and try/catch blocks.


1
Expert's answer
2021-09-27T15:47:12-0400
let mart = [];

let categoryOfItem;
let numberItem;

async promise = new Promise((resolve, reject) => }
  try {
    if (mart.includes(categoryOfItem)) {
      numberItem = mart.find(categoryOfItem);
      resolve("Item Found");
    } else {
      throw new Error();
    }
  } catch ( error ) {
    reject("Item Not Found");
  }
})

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS