In Swift, this script uses the last() function to check if the inputted character is equal to the last character in a string.
var str = "Hello, playground"
func checklastletter(word: String, letter: String) ->String {
if letter == last(word) {
return true
} else {
return false
}
}
checklastletter(str, "g")