JSFiddle - React, Tailwind, and code Playground

by Himanshu Joshi

JavaScript

function randomGen(str) {
  var idx = 0;

  var combi = [];
  combi.push(str); //root

  var rightBranch = branchs(str, combi, 0);
  debugger;
  console.log(combi);
}

function branchs(str2, combi, idx) {
  if (str2.length > 0) {
    if (combi.indexOf(str2) < 0) {
      combi.push(str2);
    }
    return branchs(str2.slice(idx, str2.length), combi, idx + 1);
  }
}

randomGen("abcd");