I have array of cars and an array of price corresponding to each car.
I want to implement the function highest3 which will return an array of 3 cars in order by their price (highest to lowest).
However, if the price is equal, then it returns the cars in alphabetical order.
In this example below, "Hummer" would be the first entry.
Code
var cars = ["Ferrari", "Lamborghini", "Jaguar", "Hummer", "Toyota"];
var price = [12, 34.5, 3.54, 45.9, 3.44];
result == ["Hummer", "Lamborghini", "Ferrari"];
function highest3 (cars, price) {
//Please help me here.
}
Can someone please help me to implement the highest3 function? I am a newbie. Thanks.