Function returns true if s1 is suffix of s2
function isSuffix ( s1 , s2 ) { var n1 = s1 . length ; var n2 = s2 . length ; if ( n1 > n2 ) return false ; for ( var i = 0 ; i < n1 ; i ++ ) if ( s1 [ n1 - i - 1 ] != s2 [ n2 - i - 1 ] ) return false ; return true ; }