Palindrome
Checks if the string entered by the user is a palindrome. That is that it reads the same forwards as backwards like “racecar”
by emeaguiar
HTML
<div id="canvas"></div>
JavaScript
canvas = document.getElementById("canvas");
var string = prompt("Enter string"),
reversedString,
result;
// Remove spaces
newString = string.split(" ").join("");
reversedString = newString.split("").reverse().join("");
if ( newString === reversedString ) {
result = " is a palindrome";
} else {
result = " is not a palindrome";
}
canvas.innerHTML = '"' + string + '"' + result;