Normalize a weather topic
Before you start this advanced track
Functions and collections. Work with immutable data, tuples, atoms, and pattern matching.
Guided code reading and debugging. Runnable coding challenges are available in JavaScript, Python, and SQL.
Understand it, then try it.
The pipe operator passes the result on its left into the first argument of the next function. A topic label travels through three clear steps: remove surrounding whitespace, replace internal spaces with hyphens, and uppercase the letters. Each function returns a new string for the next stage.
raw = " coastal weather "slug = raw |> String.trim() |> String.replace(" ", "-") |> String.upcase()IO.puts(slug)Each mission is a standalone Elixir script run with elixir. Only standard-library modules are used. Answers describe printed output, excluding any extra value an interactive IEx session would echo.
Track the values line by line. Predict the result before running this example in your own editor.