var TEST = function () { let _oriStr; let _revStr; let _ti; function _isMatch(str, si, ei) { return _oriStr.substring(si, ei+1) === _revStr.substring(_ti-ei, _ti-si+1); } return { doTest: function (str) { if (!str) { return ''; } let len = str.length; _oriStr = str; _revStr = str.split('').reverse().join(''); _ti = len - 1; const idx = { s: NaN, e: NaN }; while (len > 0) { idx.s = 0; idx.e = len - 1; while (_oriStr[idx.e]) { if (_isMatch(_oriStr, idx.s, idx.e)) { return _oriStr.substring(idx.s, idx.e+1); } idx.s++; idx.e++; } len--; } return _oriStr[0]; } }; }();