Ruby solution to for_each_in
Added JavaScript rosetta