Update solution.js

I propose a more functional and ES6 oriented solution.