RefactorU Week 3 JS exercise in functional programming