js testing for loop