Personally I would consider using javascript's build in Array.foreach() here.