Register - Login - Forgotten Password

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.

Lesson 6: Functions, Parameters and Return Values in JavaScript

This lesson just one in the category Introduction to JavaScript. To access this lesson you need to have a valid learner account, ask your parent to register you now.