Divide a number into two parts | Function to print the two parts ; Find the position of 4 ; If current character is not '4' but appears after the first occurrence of '4' ; Print both the parts ; Driver code
function twoParts ( str ) { var flag = 0 ; var a = " " ; var gfg = str . split ( ' ' ) ; for ( var i = 0 ; i < str . length ; i ++ ) { if ( gfg [ i ] == ' ' ) { gfg [ i ] = ' ' ; a += ' ' ; flag = 1 ; } else if ( flag != 0 ) a += ' ' ; } document . write ( gfg . join ( ' ' ) + " " + a ) ; } var str = " " ; twoParts ( str ) ;