Quotes help make search much faster. Example: "Practice Makes Perfect"

Saturday, December 17, 2016

Codefights isTandemRepeat(inputString)


//sample solution
function isTandemRepeat(inputString) {
    var temp=inputString.length;
    if(temp%2!=0){
        return false;
    } else {
        var midIndex = temp/2;
        var firstHalf = inputString.slice(0,midIndex);
        var secondHalf = inputString.slice(midIndex,temp);
        if(firstHalf.localeCompare(secondHalf)==0){
            return true;
        } else {
            return false;
        }
    }
}

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts