← Back to challenges

Wrap Around

JavaScriptHardstringsformattinglanguage_fundamentals

Instructions

Create a function to reproduce the wrap around effect shown:

Examples

wrapAround("Hello, World!", 2) ➞ "llo, World!He"

wrapAround("From what I gathered", -4) ➞ "eredFrom what I gath"

wrapAround("Excelsior", 30) ➞ "elsiorExc"

wrapAround("Nonscience", -116) ➞ "cienceNons"

Notes

  • The offset can be negative.
  • The offset can be greater than the length of string.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.