Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function compareNumeric(a, b) {
- if (a < b) return 1;
- if (a > b) return -1;
- }
- function fun(arr){
- newArr = [];
- for (i=0; i < arr.length; i++){
- if (arr[i] > 14){
- newArr.push(arr[i])
- }
- }
- newArr.sort(compareNumeric);
- return newArr;
- }
- arr = [1, 2, 3, 14, 50, 60, 15, 17, 18, 26, 34, 48];
- answer = fun(arr);
- alert(answer);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement