How to check whether a sentence is palindrome in Node.js

1 Answer

0 votes
function isSentencePalindrome(str) {
    // Change the string into lowercase and remove all non-alphanumeric characters
    str = str.toLowerCase().replace(/[^a-zA-Z0-9]/g, "");
    
    return str === str.split("").reverse().join("");
}

console.log(isSentencePalindrome("Al lets Della call Ed, Stella.") ? "yes" : "no");



 
/*
run:
   
yes
  
*/

 



answered Jul 1, 2024 by avibootz

Related questions

1 answer 219 views
1 answer 218 views
1 answer 216 views
1 answer 211 views
1 answer 219 views
...