Lesson 6: Functions, Parameters and Return Values in JavaScript
What happens when the same discounted-price calculation appears in five different places, and the discount rate changes? Every copy must be found and updated consistently, so one missed copy can produce the wrong price. JavaScript functions address this problem by grouping behaviour under a name that can be used whenever that behaviour is needed. The central distinction is simple: defining a function describes what it will do, while calling it makes that behaviour happen.
