Remove the First and Last Characters

Published by Pickle in

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).

Watch a quick demo on how Edabit works.