Assignment
Create a product inventory system that:
- Creates an array of at least 4 product objects, each with:
name(string)price(number)quantity(number)category(string)
- Creates a function called
calculateTotalValuethat:- Takes a product object as parameter
- Returns the total value (price * quantity)
- Creates a function called
getProductsByCategorythat:- Takes an array of products and a category string as parameters
- Returns a new array containing only products from that category
- Uses
forEachto display all products with their details - Uses a
forloop to calculate and display the total inventory value (sum of all product values) - Uses
filterto find products with low stock (quantity < 10) and display them
Requirements:
- Use arrays of objects
- Use functions with parameters and return values
- Use forEach, for loops, and filter
- Use template literals for formatting
- Use an external JavaScript file (script.js) linked to your HTML
Create an index.html file and a script.js file with your solution.