Answers for "array sort in javascript example"

-2

array sorting

/*
  Arrays Methods [Sort]
  - sort(Function [Opt])
  - reverse
*/

let myFriends = [10, "Sayed", "Mohamed", "90", 9000, 100, 20, "10", -20, -10];

console.log(myFriends);
console.log(myFriends.sort().reverse());
Posted by: Guest on July-14-2021

Browse Popular Code Answers by Language