-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuestion18.js
26 lines (26 loc) · 1.07 KB
/
Question18.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"use strict";
let placesToVisit = ["Japan", "Brazil", "Iceland", "Thailand", "Greece"];
// Print the array in its original order
console.log("Original order:");
console.log(placesToVisit);
// Print the array in alphabetical order without modifying the actual list
console.log("\nAlphabetical order:");
console.log([...placesToVisit].sort());
// Show that the array is still in its original order
console.log("\nOriginal order (again):");
console.log(placesToVisit);
// Print the array in reverse alphabetical order without changing the order of the original list
console.log("\nReverse alphabetical order:");
console.log([...placesToVisit].sort().reverse());
// Show that the array is still in its original order
console.log("\nOriginal order (again):");
console.log(placesToVisit);
// Reverse the order of the list
placesToVisit.reverse();
console.log("\nReversed order:");
console.log(placesToVisit);
// Reverse the order of the list again
placesToVisit.reverse();
console.log("\nOriginal order (again):");
console.log(placesToVisit);
// Sort the array in alphabetical