javascript example
Palindrome check in JavaScript
Test whether a string reads the same forwards and backwards. Run this JavaScript palindrome checker online.
Normalize the string (lowercase, drop spaces) before comparing it to its reverse. That way “Never odd or even” can still count as a palindrome.
split, reverse, and join are enough for a playground demo. Click Open in editor and try your own phrases.
function isPalindrome(text) {
const normalized = text.toLowerCase().replace(/[^a-z0-9]/g, "");
const reversed = [...normalized].reverse().join("");
return normalized === reversed;
}
console.log(isPalindrome("Never odd or even"));
console.log(isPalindrome("Code Arena"));