Opticallimits

Full Version: How to achieve by for loop in javascript?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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