Drawing a Christmas Tree Using Nested For Loops : For : Language Basics JAVASCRIPT DHTML TUTORIALS


JAVASCRIPT DHTML TUTORIALS » Language Basics » For »

 

Drawing a Christmas Tree Using Nested For Loops



<HTML>
<BODY>
<CENTER>
<SCRIPT
   var width=1
   for (i=0; i <= ; i++) { 
      for (x=0; x<=4; x++) { 
         for (y=1; y<=width; y++) { 
            var Number=Math.random()*10
            var Ornament=Math.round(Number)
            if (Ornament<=1) { 
               document.write("O")
            
            if (Ornament>=2)  { 
               document.write(" X")
            
         
         document.write("<BR>")
         width=width+1
      
      width=width-2
   
</SCRIPT>
</CENTER>
</BODY>
</HTML>
           
       



-

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

JAVASCRIPT DHTML TUTORIALS

 Navioo Language Basics
» For