Answers for "10.8.1.2. The isPalindrome Function"

0

10.8.1.2. The isPalindrome Function

/*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;
}
Posted by: Guest on July-01-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language