Add Javascript solution for #1