O'Reilly logo
  • Ahmed Elgendy thinks this is interesting:

Iterating through the passengers

We need a function that takes the passengers and another function that knows how to test a single passenger for some condition, like being on the no-fly list. Here’s how we do that:

image with no caption

Now all we need are some functions that can test passengers (luckily you wrote these in the previous S...


Cover of Head First JavaScript Programming


Instead of passing a function as an argument to another function; a technique which provides great deal of flexibility, we could call the function passed as an argument in the inclusive function (the bigger one). But that could mean hardcoding. In other words, you would have to invoke just the called function (passed as argument function) every time you invoke the big function.