MCPcopy Create free account
hub / github.com/marijnh/Eloquent-JavaScript / activityTable

Function activityTable

code/solutions/11_1_quiet_times.js:1–17  ·  view source on GitHub ↗
(day)

Source from the content-addressed store, hash-verified

1async function activityTable(day) {
2 let table = [];
3 for (let i = 0; i < 24; i++) table[i] = 0;
4
5 let logFileList = await textFile("camera_logs.txt");
6 for (let filename of logFileList.split("\n")) {
7 let log = await textFile(filename);
8 for (let timestamp of log.split("\n")) {
9 let date = new Date(Number(timestamp));
10 if (date.getDay() == day) {
11 table[date.getHours()]++;
12 }
13 }
14 }
15
16 return table;
17}
18
19activityTable(1)
20 .then(table => console.log(activityGraph(table)));

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected