working on functional javascript