JS Base _ Nested for loop

Source: Internet
Author: User

1 <!DOCTYPE HTML>2 <HTML>3     <Head>4         <MetaCharSet= "Utf-8" />5         <title></title>6         <Scripttype= "Text/javascript">7             8             /*9              Ten through the program, output the following graphic in the page: One                   A * 1 <1 i=0 - * * 2 <2 I=1 - * * * 3 <3 i=2 the * * * * 4 <4 i=3 - * * * * 5 <5 i=4 -                   -                  ***** +                  ***** -                  ***** +                  ***** A                  ***** at                   - * * * * 1 j<5 (5-0) i=0 - * * * * 2 j<4 (5-1) I=1 - * * * 3 j<3 (5-2) i=2 - * * 4 j<2 (5-3) i=3 - * 5 j<1 (5-4) i=4 in                   -               to              */ +              -             //-------------------------------------------------------------------------------- the              *             //output a content to the body $             //document.write ("*****<br/>");Panax Notoginseng              -              the             /*For (var i=0; i<5; i++) { + document.write ("*****<br/>"); A             }*/ the              +              -              for(varI=0; I<5; I++){ $                  for(varJ=0; J<5; J++){ $ document.write ("* "); -                 } -                 //output a line break the document.write ("<br/>"); -             }Wuyi              the              -             //output graphics with a for loop Wu             //this for loop executes several times, the height of the graph is how much -             //It can be used to control the height of the graph About              for(varI=0; I<5; I++){ $                  -                 /* - * Create a loop inside the loop to control the width of the graphic - * Currently our external for loop executes 1 times and the internal is executed 5 times A * Inner loop can be used to determine the width of the graph, how many times the width of the graph is executed +                  */ the                  -                  for(varJ=0; J<I+1; J++){ $ document.write ("*&nbsp;&nbsp;&nbsp;"); the                 } the                  the                  the                 /*For (var j=0; j<5-i; j + +) { - document.write ("*&nbsp;&nbsp;&nbsp;"); in                 }*/ the                  the                 //output a line break About document.write ("<br/>"); the                  the                  the             } +              -              the             Bayi         </Script> the     </Head> the     <Body> -          -     </Body> the </HTML>

JS Base _ Nested for loop

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.