odin-js-fundamentals-part-5/09_palindromes/palindromes.js

12 lines
338 B
JavaScript
Raw Normal View History

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;
2024-01-11 08:52:05 +00:00
};
// Do not edit below this line
module.exports = palindromes;