Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Javascript ES6 4. Write a higher order function called iteratelnventory (15 pts) This iteratelnventory function returns an updated inventory array with status This iteratelnventory function
Javascript ES6
4. Write a higher order function called iteratelnventory (15 pts) This iteratelnventory function returns an updated inventory array with status This iteratelnventory function accepts two arguments an inventory array and an evaluatelnventory function The iteratelnventory function iterates over the inventory array using .forEach() and performs evaluatelnventory The evaluatelnventory function adds a status to each item based on stock count and returns the item Stock count of 3 or more the status is 'OK' Stock count of 1 to 2 the status is 'LOW' Stock count of O is OUT OF STOCK const inventory = [ { item: 'Sony PS4 Pro', price: 399.99, stock: 3 }, { item: 'Atari', price: 125.0, stock: 0 }, { item: 'Microsoft Xbox One X', price: 499.99, stock: 1 }, { item: 'Nintendo Switch', price: 299.99, stock: 4 }, { item: 'Sony PS2 Console', price: 299.99, stock: 1 }, { item: 'Nintendo 64', price: 199.999, stock: 2 }, { item: 'Sega Genesis', price: 104.0, stock: 0 } li EXPECTED OUTPUT (array of objects): { item: 'Sony PS4 Pro', price: 399.99, stock: 3, status: 'OK' }, { item: 'Atari', price: 125, stock: 0, status: OUT OF STOCK' }, { item: 'Microsoft Xbox One X', price: 499.99, stock: 1, status: 'LOW' }, { item: 'Nintendo Switch', price: 299.99, stock: 4, status: 'OK' }, { item: 'Sony PS2 Console', price: 299.99, stock: 1, status: "LOW" }, { item: 'Nintendo 64', price: 199.999, stock: 2, status: "LOW" }, { item: 'Sega Genesis', price: 104, stock: 0, status: 'OUT OF STOCK' }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started