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