Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Function Palindrome JavaScript

function isPalindrome(str) {
  str = str.replace(/W/g, '').toLowerCase();
  return (str == str.split('').reverse().join(''));
}

console.log(isPalindrome("level"));                   // logs 'true'
console.log(isPalindrome("levels"));                  // logs 'false'
console.log(isPalindrome("A car, a man, a maraca"));  // logs 'true'

Source by www.toptal.com #
 
PREVIOUS NEXT
Tagged: #Function #Palindrome #JavaScript
ADD COMMENT
Topic
Name
5+3 =