Functional Programming
Functional programming is a style that builds programs from pure functions: functions whose result depends only on their inputs and that have no side effects such as changing shared variables. Data is treated as immutable, so new values are created instead of old ones being modified.
Functions are first-class values that can be passed to and returned from other functions (higher-order functions), and loops are often replaced by map, filter and reduce. This makes code easier to test and to run in parallel. Haskell, Elixir and Clojure are functional languages, and JavaScript, Python, Java, Kotlin and Scala support the style.
const prices = [120, 450, 80, 300];
const total = prices
.filter((p) => p >= 100) // [120, 450, 300]
.map((p) => p * 1.18) // add 18% GST
.reduce((sum, p) => sum + p, 0);
