← Back to challenges

Remove the First and Last Characters

JavaScriptHardstringsformattinglanguage_fundamentals

Instructions

Create a function that removes the first and last characters from a string.

Examples

removeFirstLast("hello") ➞ "ell"

removeFirstLast("maybe") ➞ "ayb"

removeFirstLast("benefit") ➞ "enefi"

removeFirstLast("a") ➞ "a"

Notes

If the string is 2 or fewer characters long, return the string itself (See Example #4).

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Retrieve the Subreddit