New: Cookbooks and AI ExplanationsStep-by-Step recipes to solve problems connected to Roadmaps and Cheat Sheets. Need more details? Use AI buttons for structured and simple explanations with concrete examples throughout the whole platform.Take a look
I want a script I can run from the terminal on any file, not one where I open the code and change a filename by hand.
What you'll have at the end
A command-line script that prints a line count and word count for any file you name after it
You need
A Node.js installation on your machine, and a text file you want a quick line and word count for.
Not covered
Adding extra flags such as a verbose switch, or reading piped input instead of a named file, is not covered here; this handles exactly one filename argument.
Checked 21 Aug 2026
Part of the JavaScript cookbook