Skip to content

Commit 24680f2

Browse files
Update part-three-number-sorting-easy-way.js
done
1 parent 16f14af commit 24680f2

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1-
//Sample arrays for testing:
1+
/Sample arrays for testing:
22
let nums1 = [5, 10, 2, 42];
33
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+
nums1.sort(function(a, b){
8+
return a-b
9+
});
10+
11+
console.log(nums1);
712

813
//Sort each array in descending order.
14+
nums1.sort(function(a, b){
15+
return b-a
16+
});
17+
18+
console.log(nums1);

0 commit comments

Comments
 (0)