Javascript Loop Through Array And Return New Array In Java