Reverse Words in Sentence — JavaScript easy interview problem
Given an input string `s`, reverse the order of the words. A word is defined as a sequence of non-space characters. The words in `s` will be separated by at least one space. Return a string of the words in reverse order concatenated by a single space. Extra spaces should be removed. Example: `reverseWords(" hello world ")` → `"world hello"`.
Tags: split, trim
Practice this Strings problem free in the JS Interview Playground with automated tests and unlockable solutions.