Callbacks don't have to be anonymous functions. For example, let's say we have the following function:
function square(num) {
return num ** 2;
}
Let's use it to square each element of the array:
function square(num) {
return num * num;
}
let result = each([1, 2, 3, 4, 5], square);
console.log(result);
Use the following function to cube all the elements of an array:
function cube(num) {
return num ** 3;
}