Skip to content

Commit 03d9fb6

Browse files
committed
adding .trim() method to get rid of the spaces (not counting blank lines) and get the exact number of lines
1 parent 5cbefa1 commit 03d9fb6

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

  • implement-shell-tools/wc

implement-shell-tools/wc/wc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const options = program.opts();
2828
const pathInfo = await stat(path);
2929

3030
function counter(item) {
31-
const lines = item.split("\n").length;
31+
const lines = item.trim().split("\n").length;
3232
const words = item.split(/\s+/).filter(Boolean).length;
3333
const characters = item.length;
3434
return { lines, words, characters };

0 commit comments

Comments
 (0)