Opticallimits
How to achieve by for loop in javascript? - Printable Version

+- Opticallimits (https://forum.opticallimits.com)
+-- Forum: Forums (https://forum.opticallimits.com/forumdisplay.php?fid=4)
+--- Forum: Canon EOS (https://forum.opticallimits.com/forumdisplay.php?fid=11)
+--- Thread: How to achieve by for loop in javascript? (/showthread.php?tid=4293)



How to achieve by for loop in javascript? - Shirley245 - 12-19-2018

I am learning coding for javascript. I created pyramids in console the one that i am not able to achieve is
Quote:function fnAlphabet(num){
        var result = '';
        for (var i = 1; i <= num; i++) {
            console.log(i);
            for(var j = i; j <= num; j++){
                result += j + ' ';
            }
            console.log(result);    
        }
    }
    fnAlphabet(5);

1
123
12345
1234567
123456789

Thanks for any help