Invoking a greeting function and printing its output

Report a typo

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.

Fill in the gaps with the relevant elements
 sayHello(name: String): String {
     "Hello, $name"
}

fun main() {
    val userName = "John"
    (sayHello(userName))
}
returnprintlnfun
___

Create a free account to access the full topic