-
Notifications
You must be signed in to change notification settings - Fork 3
/
scratchpad.js
58 lines (49 loc) · 1.54 KB
/
scratchpad.js
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
56
57
58
// run this file by putting "node scratchpad.js" in the terminal
const getChapterName = require("./functions/example.js");
const getAboutMe = require("./functions/aboutme.js");
const getContributors = require("./functions/githubcontributors.js");
const getOrganizers = require("./functions/organizer.js");
/*
our functions return promises, so we need to wait for the result to come back
we can either use async/await or .then() to do this
read more here:
await/async: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function
.then(): https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then
*/
getChapterName().then((chapterName) => {
if (!chapterName) {
console.log("Couldn't get chapter name");
return;
}
console.log(`Chapter name: ${chapterName}`);
});
getAboutMe().then((aboutMe) => {
if (!aboutMe) {
console.log("Couldn't get about me");
return;
}
aboutMe.forEach(function(entry){
console.log(entry);
});
});
getContributors().then((contributors) => {
if (!contributors) {
console.log("Couldn't get contributors");
return;
}
console.log("Contributors:");
// console.log(contributors);
// print the contributors (key) and their images (value)
for (const [key, value] of contributors.entries()) {
console.log(`${key}, image ${value}`);
}
});
getOrganizers().then((organizer) => {
if (!organizer) {
console.log("Couldn't get organizer");
return;
}
organizer.forEach(function(person){
console.log(person);
});
});