DEV Community

loading...

Discussion on: Code Golf Challenge: Palindrome Detector

Collapse
shijiezhou profile image
Jay Chow
function palindrome(str) {
    var splitString = str.split("");
    var halfSplitString = splitString.length / 2;
    for (var i = 0; i < halfSplitString; i++) {
        if (str[i] !== str[str.length - i - 1]) {
            return false;
        }
        else {
            return true;
        }
    }
}