odin-javascript-exercises/09_palindromes/palindromes.js

10 lines
274 B
JavaScript
Raw Normal View History

2023-06-19 17:06:09 -07:00
const palindromes = function (string) {
string = string.replace(/[^A-Za-z0-9]/g, '').toLowerCase()
const reversed = Array.from(string).reverse().reduce((res, cur) => res + cur)
2017-08-25 12:07:28 -07:00
2023-06-19 17:06:09 -07:00
return string === reversed
}
2017-08-25 12:07:28 -07:00
// Do not edit below this line
2023-06-19 17:06:09 -07:00
module.exports = palindromes