Program for length of a string using recursion | Function to calculate length ; if we reach at the end of the string ; Driver code
function recLen ( str ) { if ( str == " " ) return 0 ; else return recLen ( str . substring ( 1 ) ) + 1 ; } let str = " " ; document . write ( recLen ( str ) ) ;