Cycling Through Strings

Published by Deep Xavier in

Given two strings, repeatedly cycle through all of the letters in the first string until it is the same length as the second string.

Examples

stringCycling("abc", "hello") ➞ "abcab"

stringCycling("programming", "edabit") ➞ "progra"

stringCycling("the world in me evolves in hers", "i love Tesh, so much so") ➞ "the world in me evolves"

stringCycling("a thing of beauty is a joy forever", "indulge me surely") ➞ "a thing of beauty"

stringCycling("to", "hide") ➞ "toto"

stringCycling("such a feeling coming over me", "top of the world") ➞ "such a feeling c"

Notes

  • All tests will include valid strings.
Watch a quick demo on how Edabit works.