solve 2 in js