Function
Names and abbreviations on this page
MDN — MDN Web Docs (formerly Mozilla Developer Network). Reference material for web programming.
Programming terms & practical skills
What it means
A function packages a task so it can be called when needed. It can accept inputs called parameters and return a result. A focused function is easier to understand when its expected inputs and outputs are explicit.
Related skills
Define responsibilityGive the function one understandable purpose.
Specify inputsState the expected types and units.
Check resultsCompare a returned value with a simple worked example.
An everyday example
A function that adds monthly rent and monthly utilities can return the combined cost. Inputs of 1200 and 150 should return 1350. Adding move-in costs is a separate decision about the task's scope.
What to check
A function's name does not prove it is correct. Check its assumptions, missing-input behavior and actual result.