-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsort.js
More file actions
49 lines (44 loc) · 1.14 KB
/
Copy pathsort.js
File metadata and controls
49 lines (44 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
var arr = [2, 3, 45, 5, 6, 9,10];
arr.sort(function(a, b) {
if (a > b) return 1;
else if (a < b) return -1;
else return 0;
});
console.log(arr);
var person = [
{
name: 'A',
age: 21
},
{
name: 'B',
age: 25
},
{
name: 'C',
age: 23
},
{
name: 'D',
age: 24
}
]
person.sort(function(a,b)
{
if(a.name > b.name) return 1;
})
console.log(person);
person.sort(function(a, b) {
if (a.age > b.age) return 1;
else if (a.age < b.age) return -1;
else return 0;
});
//console.log(person);
var res1 = arr.every(function(value) {
return value > 0;
})
console.log(res1);
var res2 = arr.some(function(value) {
return value == 45;
})
console.log(res2);