← Back to challenges

Letter Shifting

JavaScriptHardalgorithmslogicstrings

Instructions

Create a function that takes a string and shifts the letters by an amount n but not the whitespace.

Examples

shiftLetters("Boom", 2) ➞ "omBo"

shiftLetters("This is a test",  4) ➞ "test Th i sisa"

shiftLetters("A B C D E F G H", 5) ➞  "D E F G H A B C"

Notes

  • Keep the case as it is.
  • n can be larger than the total number of letters.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.