Good job! In the previous exercise, we first defined the
morning_sales function and then used that function in
lapply() as the second argument. Another way is to actually place the function definition inside
lapply(); in that case, we wouldn't need the
morning_sales variable that stores the function definition.
Here's how that would look like:
We defined a nameless function on the spot, right within the argument list. That function takes a single argument (named
vector here) and returns the sum of the elements between indices 7 and 12. This is known as an anonymous function.