Introduction to Functions
Introduction to Functions: Introduction to Functions: an overview, Practice: The need for functions, Organizing code into functions, Practice: Creating…
Updated
- Introduction to Functions: an overview (Novice): When you keep repeating the same lines of code, you can turn them into a function, one reusable block you call by name.
- Practice: The need for functions (Novice): Print the scores of five football teams by copying and pasting the same code, and see why repeated code is a problem.
- Organizing code into functions (Apprentice): Learn the four parts of a function (name, parameters, return type and body), and how to call one and keep the value it returns.
- Practice: Creating Functions (Apprentice): Replace the copied team-score code with one displayTeamScores function that takes each team's rank, name and scores as parameters.