The same could said of any higher order function such as iterator methods. The simplest view, while abstract, is the simplest form:

```
Array.map(callback)
```

That description shows everything we need to map an array. We can drop in any valid function to act as the callback, or we can write a function of that name.

```
const callback = x => x ** 2;
const numbers = [2, 7, 9, 171, 52, 33, 14];
console.log(numbers.map(callback))
```

```
[ 4, 49, 81, 29241, 2704, 1089, 196 ]
```

It doesn’t make a lot of sense having a utility function like the above callback in global scope unless there is every likelihood it will be called from somewhere else in the program. It fits better in function scenario, as one of your examples demonstrates.

```
const mapSquares = arr => {
const f = x => x ** 2;
return arr.map(f);
}
const numbers = [2, 7, 9, 171, 52, 33, 14];
console.log(mapSquares(numbers))
```

```
[ 4, 49, 81, 29241, 2704, 1089, 196 ]
```

Off topic

Interesting numbers, 33 and 14. So happens our local recycling depot prefers bags with exactly 200 cans in them. After draining and removing the tab, I store them in a tray that holds 28 cans. Those then get dumped in the bag and a stroke gets added to what will eventually be a house with a stroke through it, for 7 strokes. 7 times 28 is 14 squared. Throw in four more cans, add 4 ticks and we have 200.

Back in the school days I used to bet for a jug if I could guess the outcome of their computation. Without boring you on the details, the correct solution if they followed instructions was always 1089.

This is a completely different programming language, on purpose. Watch the steps, and don’t worry about the code.

```
>>> def fn(x):
if len(str(x)) != 3: raise ValueError
y = int(str(x)[::-1]) # reverse digits
z = abs(y - x) # absolute difference
return int(str(z)[::-1]) + z # sum with reverse digits
>>>
```

```
>>> for x in range(100, 1000):
a, b, c = list(str(x)) # capture the digits
if abs(int(c) - int(a)) < 2: continue
print(f'{fn(x)}', end=',') # only valid outcomes
1089,1089,1089, # ..., 640 times
>>>
```

As we said, *if instructions are followed*. We have 90 possible 0 outcomes where the first digit matches the last, and 170 of 198 if they differ by only 1. That accounts for the missing 260. Figured out this puzzle, yet?

Hint: You really need to do this one on paper to appreciate it.