Problem · String
Last and Second-Last
Learn this problemProblem statement
Given a string, create a new string made up of its last two letters, reversed and separated by a space.
Function
lastLetters(word: String) → String
Complete the function lastLetters in the editor below.
lastLetters has the following parameter(s):
string word: a string to process
Returns
string: a string of two space-separated characters
Examples
Example 1
word = "APPLE"return = "E L"The last letter in 'APPLE' is E and the second-to-last letter is L, so return E L.
Example 2
word = "bat"return = "t a"Just an example provided by Oracle with no explanation 🥲🔫
Constraints
2 ≤ length of word ≤ 100