Imagine an addition function. This is trivial, right? A function that takes two parameters and returns a single value, the sum of those two inputs.
Imagine an incrementation function. Also trivial: a function that takes one parameter and returns a single value, the result of adding one to the input parameter.
You could write these two functions independently. But you could also choose to write the incrementation function in terms of the addition function!
Independent:
function add(x, y) {
return x + y;
}
function increment(x) {
return x + 1;
}
Expressing incrementation in terms of addition:
function add(x, y) {
return x + y;
}
function increment(x) {
return add(x, 1);
}
(Extra credit: Can you express addition in terms of incrementation? What challenges does that pose?)