Complete the code to print the length of the string.
val text = "Hello, Kotlin!" println(text.[1])
In Kotlin, length is a property of the String class that gives the number of characters.
Complete the code to convert the string to uppercase.
val greeting = "hello" val shout = greeting.[1]()
The correct function in Kotlin to convert a string to uppercase is uppercase().
Fix the error in the code to check if the string starts with "Hi".
val message = "Hi there!" val starts = message.[1]("Hi")
The correct function to check the start of a string is startsWith().
Fill both blanks to create a map of words to their lengths for words longer than 3 characters.
val words = listOf("apple", "bat", "car", "door") val lengths = words.associateWith { it.[1] }.filter { it.value [2] 3 }
Use length to get the word length and > to filter words longer than 3 characters.
Fill all three blanks to create a map of uppercase words to their lengths for words containing 'a'.
val words = listOf("apple", "bat", "car", "door") val result = words.filter { it.[1]('a') }.associate { it.[2]() to it.[3] }
Use contains to check for 'a', uppercase() to convert words, and length for their lengths.