Print Triangle separated pattern | Function to print pattern recursively ; Base Case ; Conditions to print slash ; Condition to print forword slash ; Condition to print backward slash ; Else print ' * ' ; Recursive call for rows ; Recursive call for changing the rows ; Driver Code ; Function Call
function printPattern ( i , j , n ) { if ( j >= n ) { return 0 ; } if ( i >= n ) { return 1 ; } if ( j == i j == n - 1 - i ) { if ( i == n - 1 - j ) { document . write ( " " ) ; } else { document . write ( " \\ " ) ; } } else { document . write ( " " ) ; } if ( printPattern ( i , j + 1 , n ) == 1 ) { return 1 ; } document . write ( " " ) ; return printPattern ( i + 1 , 0 , n ) ; } let N = 9 ; printPattern ( 0 , 0 , N ) ;