var counter = 0 ; pointing s2
< ! -- Javascript program for the above approach -- > function Substr ( s2 , s1 ) { var i = 0 ; for ( ; i < s1 . length ; i ++ ) { if ( counter == s2 . length ) { break ; } if ( s2 [ counter ] == s1 [ i ] ) { counter ++ ; } else {