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

Advertisements

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

Pure VPN Privide Lowest Price VPN Just @ $1.65. Per Month with Non Detected IP Lowest Price Non Detected IP VPN

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


Download Projects

Advertisements


Buy Websites 9999595223

Buy Fresh and Payment Receive Media.net Account with Website. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs