Skip to content

Instantly share code, notes, and snippets.

@jofftiquez
Last active February 1, 2018 17:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jofftiquez/9d00f02ab9420f0789462e61f6b64446 to your computer and use it in GitHub Desktop.
Save jofftiquez/9d00f02ab9420f0789462e61f6b64446 to your computer and use it in GitHub Desktop.
isPalindrome using for in
function foo(s) {
let isPalindrome = true;
for(let i in s) {
if(s[i] !== s[(s.length-1)-i]) {
isPalindrome = false;
}
}
return isPalindrome;
}
console.log(foo('lol')); // true;
console.log(foo('dota')); // false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment