0
我正在尋找一些關於爲下面的代碼創建輸出的最簡單方法的指導。只需簡單的用戶輸出到HTML文檔。任何指導都會有所幫助。還有關於如何使用連接方法的任何指導,以便我可以鏈接兩個屬性,例如Lname和accNo?Javascript創建方法 - 如何輸出
這個想法將有用戶輸入框(用於存款/取款),然後使用按鈕/按鈕來完成功能並顯示結果。
我必須指出的是,你的方法不會制定出的是
<script>
function Account(fname, lname, accNo, amount) {
this.fname = fname;
this.lname = lname;
this.accNo = accNo;
this.balance = amount;
this.bankDeposit = deposit;
this.bankWithdraw = withdraw;
}
function deposit(amount) {
this.balance += amount;
}
function withdraw(amount) {
if (amount <= this.balance) {
this.balance -= amount;
}
if (amount > this.balance) {
alert("Declined");
}
}
function joinName() {
}
var P1 = new Account("Nathan", "Smith", "SA001", 500);
var P2 = new Account("John", "Smith", "SA002", 1500);
</script>
</body>
</html>
此代碼目前正常工作嗎?.....不認爲它會工作 – raykrow
是的我在代碼上做了一些更多的工作來顯示結果,它的工作 – magpienath