JavaScript Algorithm: Reverse Words

Reverse every word in a string

Max N
Level Up Coding
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…

--

--

A writer that writes about JavaScript and Python to beginners. If you find my articles helpful, feel free to follow.