Created a for loop in js