Javascript Loop Through Array And Return New Int