-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask.txe
55 lines (35 loc) · 1.11 KB
/
task.txe
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
50
51
52
53
54
55
1) compare two json have the same properties without order
var obj1 = {
"name" : "Person1",
"age" : "5"
};
var obj2 = {
"name" : "Person1",
"age" : "5"
};
JSON.stringify(obj1) === JSON.stringify(obj2);
//false
_.isEqual(obj1 , obj2) ;
//true
2) API URL(display all the country flags in the console)
var request = new XMLHttpRequest();
request.open("get","https://restcountries.com/v3.1/all")
request.send();
request.onload = function() {
var data = request.response
var result = JSON.parse(data);
for (var i=0; i<result.length; i++) {
console.log(result[i].flags);
}
}
3) same API URL (all countries name , region , sub region ,population)
var request = new XMLHttpRequest();
request.open("get","https://restcountries.com/v3.1/all")
request.send();
request.onload = function() {
var data = request.response
var result = JSON.parse(data);
for (var i=0; i<result.length; i++) {
console.log(result[i].name.common + "/" ,result[i].region + "/" , result[i].subregion +"/" , result[i].population );
}
}