Spot the bug TypeScript
1
// Show the three cheapest deals, lowest price first.
2
function cheapestDeals(prices) {3
const sorted = [...prices].sort();
4
return sorted.slice(0, 3);
5
}
6
7
const prices = [110, 25, 9, 80, 5];
8
console.log(cheapestDeals(prices));
9
// expected: [ 5, 9, 25 ]
10
// actual: [ 110, 25, 5 ] (!)