OneCompiler

Palindrome Check Javascript

172

A JavaScript code to check whether a string is a palindrome or not

 const isPalindrome = (str) => {
  upStr = str.toUpperCase().replace(/\s+/g, '');
  fixed = upStr.split('').reverse().join('');
  
  return upStr === fixed;
  
}

const str = 'aDADA da';
console.log(isPalindrome(str));