Menu
Coddy logo textTech

Function Challenge Basics

Part of the Fundamentals section of Coddy's Kotlin journey. Lesson 16 of 93.

Some challenges give you a function to complete. The tests supply its inputs and check the value it returns. You do not write main or read console input in these tasks.

fun echoLabel(label: String): String {
    return label
}

Here fun declares a function named echoLabel. Inside the parentheses, label: String declares an input parameter. The : String after the parentheses declares the result type. Calling echoLabel("East") passes the argument "East" and produces that string.

return sends a value back to the caller and ends that function call. It does not print the value. Keep the supplied function name, parameter names and types, and return type; replace the unfinished body with your calculation. A later chapter teaches you to design and call your own functions.

Try it yourself

This lesson doesn't include a code challenge.

quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals

Practice on your own: Kotlin playground