Color theme
0 day streak0 XPP1
KotlinLearn mode
MISSION 1 OF 1

Curate a planet display

0 XP earned
Kotlin track: IntermediateMission: IntermediateCollection filteringLambda expressionsMapping
Before you start this intermediate track

Functions and collections. Read lambdas, nullable values, and conditional expressions.

Guided code reading and debugging. Runnable coding challenges are available in JavaScript, Python, and SQL.

x
0 / 2 challenges
LEARN THE CONCEPT

Understand it, then try it.

A planetarium formats names for a small display. filter keeps the elements whose condition is true, while map transforms each retained element. Inside these single-parameter lambdas, it refers to the current name. joinToString combines the resulting list into readable text using the separator supplied by the display designer.

Main.kt
fun main() {    val planets = listOf("Saturn", "Earth", "Mars", "Venus")    val display = planets.filter { it.length == 5 }        .map { it.uppercase() }    println(display.joinToString(" + "))}

Each mission is a complete independent Kotlin/JVM program with its own main function. Run it with Kotlin 1.9 or later in a Kotlin playground or a configured Kotlin/JVM project. No Android APIs are required.

Track the values line by line. Predict the result before running this example in your own editor.