JavaScript
- 33 ответа
- 0 вопросов
37
Вклад в тег
const arr = [{ name: "Creeper's Cruel Painsaw", price: '2.53', rarity: 'Common' },
{ name: "Creeper's Cruel Painsaw", price: '2.50', rarity: 'Common' },
{ name: 'Cuffs of Oak and Yew', price: '3.94', rarity: 'Rare' },
{ name: 'Cuffs of Oak and Yew', price: '4.99', rarity: 'Rare' },
{ name: 'Curled Root-Staff', price: '2.91', rarity: 'Common' },
{ name: 'Curled Root-Staff', price: '3.33', rarity: 'Common' }];
const sorted = [...arr].sort((a, b) => a.price - b.price).slice(1);
console.log(sorted); /* [
{ name: "Creeper's Cruel Painsaw", price: "2.53", rarity: "Common" },
{ name: "Curled Root-Staff", price: "2.91", rarity: "Common" },
{ name: "Curled Root-Staff", price: "3.33", rarity: "Common" },
{ name: "Cuffs of Oak and Yew", price: "3.94", rarity: "Rare" },
{ name: "Cuffs of Oak and Yew", price: "4.99", rarity: "Rare" }
] */