Skip to content

Instantly share code, notes, and snippets.

@simon0191
Created December 6, 2014 18:58
Show Gist options
  • Save simon0191/373024988f45cc840ab6 to your computer and use it in GitHub Desktop.
Save simon0191/373024988f45cc840ab6 to your computer and use it in GitHub Desktop.
function main(str) {
var mid = str.length>>1;
for(var i = 0;i<mid;++i) {
if(str[i] !== str[str.length-1-i]) return false;
}
return true;
}
console.log(main('anitalavalatina'));
console.log(main('a'));
console.log(main('aaabbbbbbaaa'));
console.log(main('aaabbbxbbbaaa'));
console.log(main('aaabbb'));
console.log(main('aaaxbbb'));
console.log(main('aabbb'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment