Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!
var palindrome = "a man a plan a canal panama"; function detectPalindrome(inThisString){ // first we remove all the white space, because we're going on the premise that it's // non significant var testString = inThisString.replace(/\W/g, ""); // then we just compare the letter at a given offset from the front to the letter of // the same offset from the back, any difference no palindrome for (var x=0;x< testString.length;x++){ if (testString[x] != testString[testString.length - (x + 1)]){ return false; } } return true; } var palindromeIsPalindrome = detectPalindrome(palindrome); var nonPalindromeIsPalindrome = detectPalindrome("rooster"); alert("Palindrome: " + palindromeIsPalindrome + "\nNon: " + nonPalindromeIsPalindrome);
#1 by Mr WordPress on August 3rd, 2009
Quote
Hi, this is a comment.
To delete a comment, just log in and view the post's comments. There you will have the option to edit or delete them.
Trackback: Антон Павлович
Trackback: Антон Павлович
Trackback: Alex Gordon
Trackback: Kylie BattName
Trackback: Kylie Batt
Trackback: Kylie Batt
Trackback: Kylie Batt
Trackback: Kylie Batt1
Trackback: BEN
Trackback: ARTURO