Revision of Map

  1. Lets take an array

    const products = [
      {id: 1, name: "Laptop", price: 80000, isAvailable: true},
      {id: 2, name: "TV", price: 50000, isAvailable: true},
      {id: 3, name: "Watch", price: 5000, isAvailable: false},
      {id: 4, name: "Phone", price: 40000, isAvailable: true},
    ];
    
  2. Extract only name of products using map.

  3. Extract only price of products using map.

  4. Extract only name and price using map.

  5. Convert all names to uppercase

  6. Add a new property price after discount where discount is 10% of MP. (better use spread operator).

  7. Add a new property category and its value must be “budget” if it is less than or equal to 40000 and “premium” if more. (spread operator)

  8. Add an new property named inStock with its value equal to isAvailable (better use spread operator).

  9. Add a new property named priceWithTax whose value if 20% of MP. (spread operator)

Filter exercises

  1. Get all available products
  2. Get all unavailable products
  3. Get products cheaper than 50,000
  4. Get products priced exactly at 50,000
  5. Get products more expensive than 50,000
  6. Get available products cheaper than 50,000
  7. Get unavailable products that cost more than 10,000
  8. Get products with name length > 5