javascript split string by for loop