12 lines
338 B
JavaScript
12 lines
338 B
JavaScript
const palindromes = function (string) {
|
|
const reversed = string.split("").reverse().join("").replace(/[\.,?! ]/g, "");
|
|
string = string.replace(/[\.,?! ]/g, "");
|
|
if (reversed.toLowerCase() === string.toLowerCase()) {
|
|
return true;
|
|
}
|
|
return false;
|
|
};
|
|
|
|
// Do not edit below this line
|
|
module.exports = palindromes;
|