forked from AC6567/geraldanekwe
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworkWithData.js
More file actions
50 lines (37 loc) · 1.08 KB
/
workWithData.js
File metadata and controls
50 lines (37 loc) · 1.08 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
50
var url = "https://api.github.com/users";
$.get(url, function(data){
var siteAdminArr = data.map(function(obj){
return obj.site_admin;
});
var adminCount = 0;
siteAdminArr.forEach(function(current){
if(current === true){
adminCount++;
}
});
var usrOrgArr = data.map(function(obj){
return obj.type;
});
var userCount = 0;
var orgCount = 0;
usrOrgArr.forEach(function(current){
if(current === "User"){
userCount++;
}else{
orgCount++;
}
});
var loginArr = data.map(function(obj){
return obj.login;
});
var loginLessThan5 = 0;
loginArr.forEach(function(current){
if(current.length <= 5){
loginLessThan5++;
}
});
console.log('Listed objects of type User: ' + userCount);
console.log('Listed objects of type Organization: ' + orgCount);
console.log('Number of admins: ' + adminCount);
console.log('Users with github handle 5 characters or shorter: ' + loginLessThan5);
});