📜  10.8.1.2. isPalindrome 函数 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:58.443000             🧑  作者: Mango

代码示例1
/*Using our reverse function for strings, we can create our palindrome 
checker. Recall that our approach will be to take the string argument, 
reverse it, and then compare the reversed string to the original 
string.*/

function reverse(str) {
   return str.split('').reverse().join('');
}

function isPalindrome(str) {
   return reverse(str) === str;
}