Why is my inventory ranker mutating the original list?
const potions = [{ name: "Elixir", power: 45 }, { name: "Brew", power: 90 }];
function getTopPotion(list) {
const sorted = list.sort((a, b) => b.power - a.power);
return sorted[0];
}
const best = getTopPotion(potions);
console.log(potions[0].name === "Elixir");
Reply with what is broken and how you would fix it.