JavaScript Loop Practice

Source: Internet
Author: User

1. Height of Blue ball bounce
Basketball from 10 meters high place falls, each bounce height is the original 0.3 times times, asked to bounce 10 times after the height of the basketball.

<script type= "Text/javascript" >    var b=10for (var a=1; a<=10;a++) {B=b*0.3}alert (b)    </script>

2. The board put food
The chessboard has 32 squares, the first lattice puts 1 sesame seeds, the second one puts 2, the third one puts 4, the fourth one puts 8 ... The weight of each sesame is 0.00001kg, if you want to fill the whole board, how much weight of sesame seeds required.

<script type= "Text/javascript" >var a=1var zhima=1for (var c=1;c<32;c++) {A=a*2;alert (a) Zhima=zhima+a        } Alert (Zhima) var d=zhima*0.00001alert (d)    </script>

3, 100 and 7 related to the number

<script type= "Text/javascript" >for (var i=0;i<100;i++) {if (i%7==0| | i%10==7| | parseint ((i%10)) ==7) {alert (i)}}        </script>

4 multiplication Formulas

<script type= "Text/javascript" >for (var i=1;i<10;i++) {for (Var j=1;j<10;j++) {if (j>i) {alert (i+ "*" +j)} }}        </script>



JavaScript Loop Practice

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.