Skip to content

Commit fd8cf2b

Browse files
authored
Create Sort Out The Men From Boys
1 parent 5ee86e8 commit fd8cf2b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Sort Out The Men From Boys

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
7 kyu
2+
Sort Out The Men From Boys
3+
4+
Task
5+
Given an array/list [] of n integers , Separate The even numbers from the odds , or Separate the men from the boys
6+
7+
8+
const menFromBoys = arr => {
9+
return [...new Set(arr.filter(value => value % 2 === 0).sort((a,b)=> a - b).concat(arr.filter(value => value % 2!== 0).sort((a, b)=> b - a)))]
10+
}
11+
12+
13+
console.log(menFromBoys([7,3,14,17]), [14,17,7,3]);
14+
console.log(menFromBoys([2,43,95,90,37]), [2,90,95,43,37]);
15+
console.log(menFromBoys([20,33,50,34,43,46]), [20,34,46,50,43,33]);

0 commit comments

Comments
 (0)