var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits = fruits.sort();
document.write(fruits);
for(var i = 0; i < Math.ceil(fruits.length / 2); i++) {
var temp = fruits[i];
fruits[i] = fruits[fruits.length - 1 - i];
fruits[fruits.length - 1 - i] = temp;
}
document.write(fruits);
I'm trying to make a reverse of the ordered (a-z) array fruits, in order to make it z-a in the for loop. Why isn't this working?