Products

Home

Part 1

Write JavaScript code to process the provided products variable to answer the questions below. Log each of the answers to the console.

  1. Display the total number of products (i.e. 3).
  2. Loop through each product and display their name and price, each on a new line.
  3. Use a filter operation to arrive at an array containing just the products that have a price less than $50, and store them in a new variable called matchingProducts.
  4. Display the total number of matching products from Question C (i.e. 2).


Part 2

Write JavaScript to programmatically populate the provided div element with information about each product. Specifically, the top-level div should contain a new child div element for each product (i.e. the product-specific div). Each product-specific div element should contain separate p tags to display the product's name, description, and price, respectively; as well as an img tag to display the image of that product; and finally a hr element to produce a horizontal line separator between each of the products.