Skip to content

Commit 35feedc

Browse files
committed
Sort
1 parent 59a30d0 commit 35feedc

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

JavaScript Interview/demo.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,16 @@ function infiniteocc(val1){
6868
return infiniteocc(val1+val2)
6969
}
7070
}
71-
console.log(infiniteocc(1)(2)())
71+
console.log(infiniteocc(1)(2)())
72+
73+
/*
74+
Sort
75+
*/
76+
let ar = [1, 9, 5, 2, 65, 6];
77+
arr.sort((a, b) => a - b); // Sort in ascending order
78+
console.log(ar); // Output: [1, 2, 5, 6, 9, 65]
79+
80+
81+
let xy = [1, 9, 5, 2, 65, 6];
82+
arr.sort((a, b) => b - a); // Sort in descending order
83+
console.log(xy); // Output: [65, 9, 6, 5, 2, 1]

0 commit comments

Comments
 (0)