Extracting first character and computing message length

Report a typo

Alice sends messages through an automated system which tags user details like the receiver's name, and their age. She realizes that many times, the first character of the message and the length of the entire message play a critical role in interpreting the messages correctly. Fill the blanks in the code fragment to extract the first character of the message and compute the length of the entire message.

Fill in the gaps with the relevant elements
fun main() {
    val name = "Alice"
    val age = 20
    val message = "Hello, $name! You are $age years old."
    val firstChar = message.()
    println("First character of the message is '$firstChar'.")
    println("Message Length: ${message.}.")
}
lengthfirst

Create a free account to access the full topic