Medium
This question is a daily question and will count towards your daily streak.
Santa needs to sort the list of presents based on their priority. However, there's a slight issue with how the gifts are being ordered. What’s wrong with this code?
1const presents = [2 { name: 'Toy Train', priority: 2 },3 { name: 'Teddy Bear', priority: 3 },4 { name: 'Christmas Sweater', priority: 1 },5 { name: 'Candy Cane', priority: 4 }6];78const sortedPresents = presents.sort((a, b) => a.priority - b.priority);9console.log(sortedPresents);