Javascript String subsetStrings()

Description

Javascript String subsetStrings()


String.prototype.subsetStrings = function(){
    var result = [];
    for (var i = 0; i < this.length; i++){
        for (var j = i + 1; j <= this.length; j++){
            result.push(this.substring(i,j));
        }/*w w  w. ja  v  a  2  s . c o m*/
    }
    return result;
};

var s = 'dog';

console.log(s.subsetStrings());



PreviousNext

Related