Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to achieve by for loop in javascript?
#1
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
  


Messages In This Thread
How to achieve by for loop in javascript? - by Shirley245 - 12-19-2018, 07:47 AM

Forum Jump:


Users browsing this thread:
1 Guest(s)