码迷,mamicode.com
首页 > 其他好文 > 详细

07_ for 练习 _ sumOfOdd

时间:2018-09-19 23:33:04      阅读:197      评论:0      收藏:0      [点我收藏+]

标签:head   lse   meta   set   class   ack   round   rip   var   

  • <!DOCTYPE html>
    <html>
        <head>
            <meta charset="utf-8" />
            <title>Sum of Odd/Even</title>
        </head>
        <body>
            <script type="text/javascript">
                var sumOdd = 0;
                var sumEven = 0;
                var i;
                
                for(i=1; i<=100; i++)
                {
                    if(i%2 != 0)
                    {
                        sumOdd += i;
                    }
                    else
                    {
                        sumEven += i;
                    }
                }
                document.write("The sum of 1~100 odd is "+sumOdd+"<br />");
                document.write("The sum of 1~100 even is "+sumEven+"<br />");
            </script>
        </body>
    </html>

     

07_ for 练习 _ sumOfOdd

标签:head   lse   meta   set   class   ack   round   rip   var   

原文地址:https://www.cnblogs.com/tianxiaxuange/p/9678167.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!