Menu
CoddyTech

Word Counter

Part of the PowerShell Basics section of Coddy's PowerShell journey. Lesson 27 of 28.

challenge icon

Challenge

Medium

Read a sentence and report on its words.

  1. Read a line with the prompt Sentence. Words are separated by single spaces.
  2. Print Words: and the number of words.
  3. Print Longest: and the longest word. When several words share the longest length, print the first of them.
  4. Print Long words: and how many words have more than 4 characters.
  5. 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 The

Try it yourself

# Read the sentence and report on its words

All lessons in PowerShell Basics