-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreport.js
More file actions
35 lines (27 loc) · 715 Bytes
/
report.js
File metadata and controls
35 lines (27 loc) · 715 Bytes
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
function printReports(pages) {
console.log("===============");
console.log("REPORT");
console.log("===============");
const sortedPages = sortpages(pages)
for (const sortedPage of sortedPages) {
const url = sortedPage[0]
const hits = sortedPage[1]
console.log(`Found ${hits} links to page : ${url}`);
}
console.log("===============");
console.log("END REPORT");
console.log("===============");
}
function sortpages(pages) {
const pageArr = Object.entries(pages);
pageArr.sort((a, b) => {
const aHits = a[1];
const bHits = b[1];
return bHits - aHits;
});
return pageArr;
}
module.exports = {
sortpages,
printReports,
};