Update solution.js

This is my solution.
I'm asking for a merge but what I want is to talk with you and understand wich one solution is best suited for this problem and why.
Many thanks for your time.
Daniele.