Print Number Pattern in JavaScript

Advertisements

Prev Tutorial Next Tutorial

Print Number Pattern in JavaScript

Using JavaScript we can easly write any programming code, Here we write one of the most popular program Print Star Pattern in JavaScript. To perform this task we need for loop.

Number Pattern in JavaScript

<html>
<head>
<script type="text/javascript">

  var a;
var n=prompt("Enter a number for the no. of rows in a pattern");
for(var i=1;i<=n;i++)
 {
  for(var j=1;j<=i;j++)
   {
    document.write("0"+j+" ");
   }
   document.write("<br />");
 }

</script>
</head>
<body>
</body>
</html>

Output

01 
01 02 
01 02 03 
01 02 03 04 
01 02 03 04 05 

Number Pattern in JavaScript

<html>
<head>
<script type="text/javascript">

 for(i=1; i <= 5; i++)
 {
  for(j=1; j<=i; j++)
 {
   document.write(j);
   if(j == i)
   continue;
   else
   document.write(' ');
  }
   document.write('<br />');
  }
    
</script>
</head>
<body>
</body>
</html>

Output

1
1 2
1 2 3
1 2 3 4
1 2 3 4 5

Prev Tutorial Next Tutorial

Google Advertisment

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet


For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements