Home  • Programming • JavaScript

JavaScript program to print ascii patterns

Code Solutions [4384] Problem Definition Write a JavaScript program which will print as the following ASCII patterns: a. * ** *** **** ***** ****** b. ***** **** *** ** * c. ***** ***** ***** ***** Code a.
<script>
for(i=0;i<5;i++){
   for(j=0;j<=i; j++){
       document.write("*");
  }
document.write("<br/>");
}

</script>
b.
<script>
for(i=0;i<5;i++){
   for(j=0;j<=5-i; j++){
       document.write("*");
  }
document.write("<br/>");
}

</script>
c.
<script>
for(i=0;i<5;i++){
   for(j=0;j<=5; j++){
       document.write("*");
  }
document.write("<br/>");
}

</script>

Comments 1


I don't understand

Share

About Author
Administrator