06_ for 练习 _ 年利率

  • <!DOCTYPE html>
    <html>
        <head>
            <meta charset="utf-8" />
            <title>Money Growing.</title>
        </head>
        <body>
            <script type="text/javascript">
                var tax = 0.05;
                var money = 1000;
                var year;
                
                for(year=1; money<1000; year++)
                {
                    money += money*tax;
                    alert(money);
                }
                year--;
                document.write(year+" years , you got "+money);
            </script>
        </body>
    </html>

     

posted @ 2018-09-19 22:20  耶梦加德  阅读(120)  评论(0编辑  收藏  举报