<!doctype html><html><head><meta charset="utf-8"><title>JS语法练习3</title><script> var amount = 0; function bankSystem(behavior,number){ if(behavior="save"){amount=amount+number;return amount;} if(behavior="withdraw"){amount=amount-number;return amount;} } function checkAmount(){ document.write(amount+"<br>"); } bankSystem("save",1000); checkAmount(); bankSystem("withdraw",300); checkAmount(); bankSystem("withdraw",850); checkAmount(); bankSystem("save",700); checkAmount(); bankSystem("withdraw",60); checkAmount(); bankSystem("save",100); bankSystem("save",200); bankSystem("withdraw",1000); bankSystem("save",500); bankSystem("withdraw",200); checkAmount(); </script></head><body></body></html>
1 回答
已采纳
摩诃迦叶
TA贡献146条经验 获得超54个赞
if(behavior="save"){amount=amount+number;return amount;}
if(behavior="withdraw"){amount=amount-number;return amount;}
behavior="save"这是赋值语句不是比较。 比较是behavior=="save"
添加回答
举报
0/150
提交
取消