← Back to challenges

Concatenating First and Last Character of a String

JavaScriptHardstringslanguage_fundamentals

Instructions

Create a function that takes a string and returns the concatenated first and last character.

Examples

firstLast("ganesh") ➞ "gh"

firstLast("kali") ➞ "ki"

firstLast("shiva") ➞ "sa"

firstLast("vishnu") ➞ "vu"

firstLast("durga") ➞ "da"

Notes

There is no empty string.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Slice of Pie