[javascript] How to write palindrome in JavaScript

This tests each end of the string going outside in, returning false as soon as a lack of symmetry is detected. For words with an odd number of letters, the center letter is not tested.

function isPalindrome(word){
    var head = 0;
    var tail = word.length - 1;

    while (head < tail) {
        if (word.charAt(head) !== word.charAt(tail)){
            return false
        } else {
            head ++;
            tail --;
        }
    };
    return true;
};