I have this code:
var al = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"];
function output(a, ind) {
if (!ind) {
ind = 0;
}
if (ind < 26) {
var newtext = document.createTextNode(recursString(a[ind], ind));
var br = document.createElement("br");
var para = document.getElementById("hello");
para.appendChild(newtext);
para.appendChild(br);
output(a, ++ind);
}
}
var iter = 0;
var s = "";
function recursString(str, i) {
if (i === 0) {
s += str;
return s;
}
if (iter < i) {
s += str;
iter++;
recursString(str, i);
}
return s;
}
It outputs strings like this:
A
AB
ABC
ABCD
ABCDE
etc.
But i need:
A
BB
CCC
DDDD
EEEEE
etc.
I need to use only recursion.
I suspect, according to debugging, s variable doesn't work like it should..
How do i fix it to make it work the way i want?