DML School of Technology
Menu

Getting going, Strings

Words backwards

The task

Return the sentence with its words in reverse order (the letters in each word stay as they are). Words are separated by single spaces.

Write a function called reverseWords.

Tests

CallExpectedYours
reverseWords("I love Lagos") "Lagos love I" not run
reverseWords("one") "one" not run
reverseWords("code every day") "day every code" not run

Next challenge · All challenges

solution.js

Tab indents. To leave the editor, press Escape, then Tab.

Output

Run prints what your code prints. Run the tests to check your function.