Check length

Report a typo

Here is a program that uses the check function according to this logic: if the length of the input string is greater than 5, it returns null; otherwise it returns the string. Do not change the check function: fix the output. It has to return 0 in null case.

Sample Input 1:

danger

Sample Output 1:

0

Sample Input 2:

Bob

Sample Output 2:

3
Write a program in Kotlin
fun main() {
val argument = readLine()!!
println(check(argument).length)
}

// do not change function below

fun check(name: String): String? {
return if (name.length > 5) null else name
}
___

Create a free account to access the full topic