Javascript Array Question 2 sort and reverse

Introduction

We would like to sort an array and then reverse it.

Code structure

let myShopping = ["Eggs", "Milk", "Potatoes", "Cereal",  "Banana"]; 
//your code here



let myShopping = ["Eggs", "Milk", "Potatoes", "Cereal",  "Banana"]; 

myShopping.sort(); 
console.log(myShopping.join(" ")); 

myShopping.sort(); 
myShopping.reverse(); 
console.log(myShopping.join(" ")); 



PreviousNext

Related