Skip to content

Commit a324eef

Browse files
author
Craig D'Silva
committed
Remove 0s from unwanted data
1 parent 62821e4 commit a324eef

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

  • implement-shell-tools/wc

implement-shell-tools/wc/wc.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,11 @@ for (let i = 0; i < stringArr.length; i++) {
5252
infoArr.push(arr.join(" "))
5353
}
5454

55-
if (infoArr.length > 1) infoArr.push([lines, words, bytes, "total"].join(" "))
55+
if (infoArr.length > 1) {
56+
const totalArr = ["total"];
57+
if (showByteCount) totalArr.unshift(bytes);
58+
if (showWordCount) totalArr.unshift(words);
59+
if (showLineCount) totalArr.unshift(lines);
60+
infoArr.push(totalArr.join(" "))
61+
}
5662
console.log(infoArr.join("\n"))

0 commit comments

Comments
 (0)