javascript function to transform string to add character upfront 1 21 321

Solutions on MaxInterview for javascript function to transform string to add character upfront 1 21 321 by the best coders in the world

showing results for - "javascript function to transform string to add character upfront 1 21 321"
Mariana
27 Apr 2016
1function triangleNumber(num) {
2    if(num>15) return;
3    var str = '';
4    for(var i = num; i >= 1 ; i--)  str += i;
5    console.log(str);
6    triangleNumber(num-1)
7}
8
9triangleNumber(1);