Question 3
Consider the following JavaScript code
const juices = [ { id: 1, name: "grape", rating: 8.1 }, { id: 2, name: "apple", rating: 5.0 }, { id: 3, name: "orange", rating: 6.9 }, { id: 4, name: "banana", rating: 10 },]
mapping = { "4": 1, "3": 2, "2": 3, "1": 4 }
juices.map((juice) => { return { ...juice, rank: mapping[juice.id] } }) .sort((a, b) => a.rank - b.rank) .map((juice) => { console.log(juice.name) })What will be the output of the code?