Increment j by 2
j = j + 2 ; let firstPart = str . substr ( 0 , i ) ; let lastPart = str . substr ( i + 1 ) ; str = firstPart + ' ' + lastPart ; i += 1 ; continue ; } let firstPart = str . substr ( 0 , i ) ; let lastPart = str . substr ( i + 1 ) ; str = firstPart + str [ j ] + lastPart ; i += 1 ; j += 1 ; } if ( j == len - 1 ) { let firstPart = str . substr ( 0 , i ) ; let lastPart = str . substr ( i + 1 ) ; str = firstPart + str [ j ] + lastPart ; i += 1 ; }