Add #40 JavaScript solution