You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

solution-exercise-5.js 323B

123456789101112
  1. function isPalindrome(input) {
  2. const regex = /[\W_]/g;
  3. input = input.toLowerCase().replace(regex, '');
  4. let len = input.length;
  5. for (let i = 0; i < len/2; i++) {
  6. if (input[i] !== input[len - 1 - i]) {
  7. return false;
  8. }
  9. }
  10. return true;
  11. }
  12. console.log(isPalindrome("A man, a plan, a canal. Panama"));