Javascript String subStrings(string)

Description

Javascript String subStrings(string)


String.prototype.subStrings = function (string) {
  var string_array = [];
  for (var i = 0; i < string.length-1; i++) {
    for (var j = i; j < string.length; j++) {
      string_array.push(string.slice(i, j + 1));
    }//from ww  w  .  ja v a2  s. c o  m
  }
  console.log(string_array);
};

String.prototype.subStrings("cat");



PreviousNext

Related