← Back to challenges

Compounding Letters

JavaScriptHardstringsformattingloops

Instructions

Create a function that takes a string and returns a new string with each new character accumulating by +1. Separate each set with a dash.

Examples

accum("abcd") ➞ "A-Bb-Ccc-Dddd"

accum("RqaEzty") ➞ "R-Qq-Aaa-Eeee-Zzzzz-Tttttt-Yyyyyyy"

accum("cwAt") ➞ "C-Ww-Aaa-Tttt"

Notes

  • Capitalize the first letter of each set.
  • All tests contain valid strings with alphabetic characters (a-z, A-Z).
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Slidey Numbers