Reputation: 385
I have the higher price value and lower price value. And i have a array..so now i need to filter the array between high price and low price
High price = 90;
low price = 20;
actual array = [
{ price: "10" },
{ price: "30" },
{ price: "40" },
{ price: "70" },
{ price: "90" },
{ price: "100" }
];
So now after filter i need only in between values.like this
array = [
{ price: "30" },
{ price: "40" },
{ price: "70" },
{ price: "90" }
];
Upvotes: 0
Views: 68
Reputation: 38094
You can use filter
method:
let array = [
{ price: "10" },
{ price: "30" },
{ price: "40" },
{ price: "70" },
{ price: "90" },
{ price: "100" }
];
let highPrice = 90;
let lowPrice = 20;
const result = array.filter(s => s.price >= lowPrice && s.price <= highPrice)
console.log(result)
Upvotes: 2