Js Iterate Through Array Javascript Function