JavaScript with Arrays

Updated with For loop