Skip to content

Commit 4a83836

Browse files
committed
part three studio completed and saved a lot of time with the sort method
1 parent 1c5c0b1 commit 4a83836

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

more-on-functions/studio/part-three-number-sorting-easy-way.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,13 @@ let nums2 = [-2, 0, -10, -44, 5, 3, 0, 3];
44
let nums3 = [200, 5, 4, 10, 8, 5, -3.3, 4.4, 0];
55

66
//Sort each array in ascending order.
7+
console.log("Ascending: ")
8+
console.log(nums1.sort(function(a, b){return a-b}));
9+
console.log(nums2.sort(function(a, b){return a-b}));
10+
console.log(nums3.sort(function(a, b){return a-b}));
711

812
//Sort each array in decending order.
13+
console.log("Descending: ")
14+
console.log(nums1.sort(function(a, b){return b-a}));
15+
console.log(nums2.sort(function(a, b){return b-a}));
16+
console.log(nums3.sort(function(a, b){return b-a}));

0 commit comments

Comments
 (0)