Skip to content

Commit 0b3d37d

Browse files
committed
correctly print out totals, includning flags
1 parent bdfbbba commit 0b3d37d

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

  • implement-shell-tools/wc

implement-shell-tools/wc/wc.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ for (const path of paths) {
6666
}
6767
}
6868

69+
// if there's more than one file, print out a total
70+
// if a flag is not selected, then the value for that flag is 0
71+
// filter out anything with a total of 0
6972
if (fileCount > 1) {
70-
console.log(`\t${totals.l}\t${totals.w}\t${totals.c} total`);
73+
const totalsArr = Object.values(totals).filter((elem) => elem !== 0);
74+
console.log(`\t${totalsArr.join("\t")} total`);
7175
}

0 commit comments

Comments
 (0)