You are creating a Kotlin application that will greet users. To accomplish this, you have a helper function called sayHello which takes in a user's name as a string and returns a greeting. In your main function, you get the username as 'John' stored in variable userName. You need to print the greeting. Please fill in the blanks in the following code to correctly invoke the sayHello function and print the output to the console.
Invoking functions
Invoking a greeting function and printing its output
Report a typo
Fill in the gaps with the relevant elements
sayHello(name: String): String {
"Hello, $name"
}
fun main() {
val userName = "John"
(sayHello(userName))
} ___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.