用ionic 3中的两个值过滤数组
filter the array with two value in ionic 3
我有较高的价格值和较低的价格值。我有一个数组..所以现在我需要在高价和低价之间过滤数组
High price = 90;
low price = 20;
actual array = [
{ price: "10" },
{ price: "30" },
{ price: "40" },
{ price: "70" },
{ price: "90" },
{ price: "100" }
];
所以现在过滤后我只需要在 values.like 这个
之间
array = [
{ price: "30" },
{ price: "40" },
{ price: "70" },
{ price: "90" }
];
您可以使用filter
方法:
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)
我有较高的价格值和较低的价格值。我有一个数组..所以现在我需要在高价和低价之间过滤数组
High price = 90;
low price = 20;
actual array = [
{ price: "10" },
{ price: "30" },
{ price: "40" },
{ price: "70" },
{ price: "90" },
{ price: "100" }
];
所以现在过滤后我只需要在 values.like 这个
之间array = [
{ price: "30" },
{ price: "40" },
{ price: "70" },
{ price: "90" }
];
您可以使用filter
方法:
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)