← Back to challenges

Reverse the String (with a catch)

JavaScriptHardstringsformatting

Instructions

Create a function that takes a string and returns the reversed string. However there's a few rules to follow in order to make the challenge interesting:

  • The UPPERCASE/lowercase positions must be kept in the same order as the original string (see example #1 and #2).
  • Spaces must be kept in the same order as the original string (see example #3).

Examples

specialReverseString("Innokodakademija") ➞ "Tibade"

specialReverseString("UPPER lower") ➞ "REWOL reppu"

specialReverseString("1 23 456") ➞ "6 54 321"

Notes

N/A

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.