Javascript program to create the equivalent of the Ruby methods each, map! and induce