Question: Create a function called priceFilter that returns all the items whose price is under a certain amount. The function should take in two arguments, an

Create a function called priceFilter that returns all the items whose price is under a certain amount.

The function should

  • take in two arguments, an array of items and an amount (a number)
  • return an array of items that have a price below the amount.

For example, here's what the function should return when we pass in the sample items and the amount 50:

priceFilter(items, 50) //* [ { itemName: "Effective Programming Habits", type: "book", price: 13.99 } { itemName: "Finding Your Center", type: "book", price: 15.00 } ] */ 

As shown in the example shopping cart data below, the shopping cart is an array of items. Each item is an object with keys itemName, type, and price.

Notes

  • If there are no items have a price below the amount, your priceFilter function should return an empty array [].

here is what I have so far

function priceFilter(items, number){ let cost = 0; for(let i =0; i < items.length; i++){ if(items[i].price > number);

I need help please im lost I dont know how to get far

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!