Word Counter
Part of the PowerShell Basics section of Coddy's PowerShell journey. Lesson 27 of 28.
Challenge
MediumRead a sentence and report on its words.
- Read a line with the prompt
Sentence. Words are separated by single spaces. - Print
Words:and the number of words. - Print
Longest:and the longest word. When several words share the longest length, print the first of them. - Print
Long words:and how many words have more than 4 characters. - Print
Reversed:and the words in reverse order, separated by single spaces.
With the input The quick brown fox jumps, your script prints:
Sentence: The quick brown fox jumps
Words: 5
Longest: quick
Long words: 3
Reversed: jumps fox brown quick TheTry it yourself
# Read the sentence and report on its words
All lessons in PowerShell Basics
5Project: Password Checker
Project OverviewLength Check