How to fix this function? (If able let me see the full source code)

Please help me to complete the online programmer Academy. I have spent 8 hours looking for the point of the problem but until now I did not find the problem sought as well as the solution.


Complete the code snippet in a simple program on the side to be able to run well.

Complete the declaration of the getFirstAndLast function which becomes an extension of the String class with the return type of the Map<String, Char> which serves to get the first and last character of its receiver value.

Add a function to print the values of the firstChar and lastChar variables on the console.

If it is run, the console displays the following text:

First Letter is K and N for second letter

You can get any character in a string by its index.

val charAtIndex4 = someString[4]

Indices always start at 0 so the first char will always be someString[0]. You can get the last char by using someString[someString.lenght - 1]. Also kotlin has extension functions to get the first/last element of any iterable/character sequence (including string).

val first = someString.first()
val last = someString.last()

How about the implementation about the code it’s written on that picture? I don’t know the exact location of where to place the code…