I have this function which prints the numbers from 1 to n in a triangle like way.
function printNumbers(n) {
var result = "";
var counter = 1;
while (counter <= n) {
result += counter;
console.log(result);
counter = counter + 1;
}
}
console.log(printNumbers(4));
the result looks like this:
1
12
123
1234
I need pointer on how to do this using recursion, because I am new to programing an I don't have a clue on how to do it.