Add code where indicated to invoke deposit
to add 150.00 to account1. Then use the apply
keyword to invoke deposit
to add 75.00 to account2. Then use the call
keyword to invoke deposit
to add 10.00 to account3.Note that the following exercise is for drill only, i.e. we would normally not organize code this way.
<html>
<script>
var account1 = {
balance: 12345.33,
deposit: function(amount) {
// Add code here...
}
};
var account2 = {
balance: 345.21
};
var account3 = {
balance: 10000.00
};
// And more code here
// Code test
function test(x) {
if (x)
document.write("pass<br>");
else
document.write("FAIL<br>");
}
document.write("Test Results<br>");
var value = 12345.33 + 150.00;
document.write("account1.balance is: "+account1.balance+" and should be: "+value+"<br>");