exercising functional javascript