JavaScript Algorithm: Reverse Words
Reverse every word in a string
Published in
2 min readJul 23, 2021
We are going to write a function called reverseWords
that accepts a string, str
, as an argument.
You are given a string of varying word counts. The goal of the function is to reverse every word in the string and return it.
Example:
reverseWords('The quick brown fox jumps over…