Divide a string in N equal parts | Method to print n equal parts of str ; Check if string can be divided in n equal parts ; Calculate the size of parts to find the division points ; length od string is 28 ; Print 4 equal parts of the string
function divideString ( str , n ) { let str_size = str . length ; let part_size ; if ( str_size % n != 0 ) { document . write ( " " + " " ) ; return ; } part_size = parseInt ( str_size / n , 10 ) ; for ( let i = 0 ; i < str_size ; i ++ ) { if ( i % part_size == 0 ) document . write ( " " ) ; document . write ( str [ i ] ) ; } } let str = " " ; divideString ( str , 4 ) ;