text: Print the string after the specified character has occurred given no . of times | Method to print the string ; If given count is 0 print the given string and return ; Start traversing the string ; Increment occ if current char is equal to given character ; Break the loop if given character has been occurred given no . of times ; Print the string after the occurrence of given character given no . of times ; Otherwise string is empty ; Driver Method
code: function printString ( str , ch , count ) { var occ = 0 , i ; if ( count == 0 ) { document . write ( str ) ; return ; } for ( i = 0 ; i < str . length ; i ++ ) { if ( str . charAt ( i ) == ch ) occ ++ ; if ( occ == count ) break ; } if ( i < str . length - 1 ) document . write ( str . substring ( i + 1 ) ) ; else document . write ( " " ) ; } var str = " " ; printString ( str , ' ' , 2 ) ;