break out of for loop in javascript