1
2
3
4
5 | var input = 'some.tree.structure.to.parse'; var wantedOutput = ['some', 'some.tree', 'some.tree.structure', 'some.tree.structure.to', 'some.tree.structure.to.parse']; |
1 | function go(s){var l=n=s.split(".");l=n.length;for(i=1;i<l;i++){n[i]=n[i-1]+'.'+n[i]}return n} |
1 | function go(s,n=s.split(".")){for(i=1;i<n.length;i++){n[i]=n[i-1]+'.'+n[i]}return n} |
1 | function go(s,n=s.split(d=".")){for(i=1;n.length-i;)n[i]=n[i-1]+d+n[i++];return n} |