Returns true if first and last characters of s are same .
function checkEquality ( s ) { return ( s . charAt ( 0 ) == s . charAt ( s . length - 1 ) ) ; } function countSubstringWithEqualEnds ( s ) { var result = 0 ; var n = s . length ;