Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MongoDB Applied Design Patterns Practical Use Cases With The Leading NoSQL Database

Authors: Rick Copeland

1st Edition

1449340040, 978-1449340049

More Books

Students also viewed these Databases questions

Question

Explain the meaning of ergonomics.

Answered: 1 week ago

Question

5. A review of the key behaviors is included.

Answered: 1 week ago

Question

3. An overview of the key behaviors is presented.

Answered: 1 week ago