polyndrome

Benchmark created on


Setup

const text = 'abcfdeghij jihgedfcba';

Test runner

Ready to run.

Testing in
TestOps/sec
comparison by char at
const isPolyndrome = (text) => {
    let flag = true;
    const textLength = text.length;
    for(let i = 0; i < (textLength >> 1); i++) {
        const left = text.charAt(i);
        const right = text.charAt(textLength - 1 - i);
        if(left !== right) {
            flag = false;
            break;
        }
    }
    return flag;
};
const result = isPolyndrome(text);
ready
inbuilt comparison
const isStringPolyndrome = (text) => {
    const str = text.toLowerCase();
    return str === str.split('').reverse().join('');
};
const result = isStringPolyndrome(text);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.