Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

palindrome in javascript

function palindrome(str) {

    var len = str.length;
    var mid = Math.floor(len/2);

    for ( var i = 0; i < mid; i++ ) {
        if (str[i] !== str[len - 1 - i]) {
            return false;
        }
    }

    return true;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #palindrome #javascript
ADD COMMENT
Topic
Name
6+5 =