It’s fun when you can pass the fun into another fun as a parameter. Ow, fun means function :p . Every…