Creating a greeting function for a username

Report a typo

John is a novice Kotlin programmer. He wants to create a function that takes a user name as input and returns a greeting message displaying that name. He wants to invoke that function with a value containing 'Kotlin Learner'. He has started the program, but some keywords and symbols are missing. Your task is to help John by filling the blanks in the code.

Fill in the gaps with the relevant elements
 greet(name: String): String { 
     "Hello, $name!" 
}
val myName: String = "Kotlin Learner"
(greet(myName))
funreturnprintln
___

Create a free account to access the full topic