Print pyramid pattern of numbers and stars

Notes:

Print pyramid patterns of numbers and stars
Displaying patterns using javascript nested for loop:

var rows=5;
for(var i=1;i<=rows;i++)
{
for(var j=1;j<=i;j++)
{
document.write(" * ");
}
document.write("<br/>");
}
Output:
*
* *
* * *
* * * *
* * * * *

Displaying pyramid using for loop:

var rows = 5;
for(var i=1; i<=rows; i++)
{
for(var k=1; k<=( rows-i ); k++)
{
document.write(" ");
}
for(var j=1; j<=i; j++)
{
document.write("* ");
}
document.write("<br/>");
}
Output:
     *
   * *
  * * *
 * * * *
* * * * *

Interview Questions: