Build a tiny version of the Unix wc command. Given a list of lines, return the total number of lines as an integer.
Function signature:
func countLines(lines []string) int
Example:
Input: lines = ["hello", "world", "foo", "bar", "baz"] Output: 5
Every entry of the list is one line, even an empty string "". An empty list has 0 lines.
The number of lines is just the slice's length. Use the built-in
len(lines).
A one-liner:
func countLines(lines []string) int {
return len(lines)
}
Free plan: 30 tutor messages. Premium is unlimited.
Saved
Ctrl + Enter to check
