execise using for loop in JavaScript