function myMap(arr, fn) {
const result = [];
for (const item of arr) result.push(fn(item));
return result;
}
myMap([1, 2, 3], x => x * 2); // [2, 4, 6]A higher-order function takes another function as an argument to customize behavior.
Higher-order functions accept other functions as arguments or return functions.
Challenge: Implement myMap that takes an array and a function, applies the function to each element, and returns a new array with the results.