← Back to challenges

Modifying the Last Character

JavaScriptHardstringslanguage_fundamentals

Instructions

Create a function which makes the last character of a string repeat n number of times.

Examples

modifyLast("Hello", 3) ➞ "Hellooo"

modifyLast("hey", 6) ➞ "heyyyyyy"

modifyLast("excuse me what?", 5) ➞ "excuse me what?????"

Notes

  • Tests will include numbers and punctuation.
  • Make sure your code is not case sensitive.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Burglary Series (07): Make a Copy