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

Find a train platform

0 XP earned
Dart track: IntermediateMission: BeginnerMapsDynamic keysLookup
Before you start this intermediate track

Typed functions and maps. The lessons use named parameters and nullable values.

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 map connects keys to values. This station map connects destination names to platform labels, so the program can look up a destination selected by the traveler. Square brackets use the value inside destination as the key. The program prints the matching label without depending on the map entry order.

travel_helper.dart
void main() {  final platforms = {'cedar': 'B4', 'harbor': 'D2'};  final destination = 'harbor';  final platform = platforms[destination];  print(platform);}

Each mission is a complete Dart 3 program with its own main function. Run one at a time with dart run. Only the built-in dart:core library is used; Flutter is not required.

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