← Back to challenges

Is a String Stretched?

JavaScriptHardstringsvalidation

Instructions

Write a function that returns true if the first string is the second string stretched, and false otherwise. A stretch is to repeat each character in a string the same number of times.

Examples

isStretched("pppaaannndddaaa", "panda") ➞ true

isStretched("sssshhiipp", "ship") ➞ false

isStretched("magnet", "magnet") ➞ true

isStretched("magneto", "magnet") ➞ false

Notes

  • Both strings must contain the same letters in order for the stretch to be valid.
  • All strings will be in lower case letters.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.