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
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