苦逼的程序员!没事就意淫下!想想每天都是正能量!娶妻生子买房买车不是问题啊!
function showMoney(basemoney,increase,years){ var amountMoney=0; for(var i=1;i<years+1;i++){ console.log("第"+i+"年的工资"+basemoney+"元"); basemoney+=basemoney*increase; amountMoney+=basemoney*12; console.log("第"+i+"年的总工资"+basemoney*12+"元"); } console.log("这是你"+years+"年总共的工资为"+amountMoney+"元"); return amountMoney; } function useMoney(basemoney,increase,years){ var amountMoney=0; for(var i=1;i<years+1;i++){ console.log("第"+i+"每个月的花费"+basemoney+"元"); basemoney+=basemoney*increase; amountMoney+=basemoney*12; console.log("从工作到第"+i+"年总共花费"+basemoney*12+"元"); } console.log("这是你"+years+"年总共的开销为"+amountMoney+"元"); return amountMoney; }
原文地址:http://blog.csdn.net/zz3hh/article/details/39993861