Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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;
}
Source by education.launchcode.org #
 
PREVIOUS NEXT
Tagged: #The #isPalindrome #Function
ADD COMMENT
Topic
Name
5+1 =