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.

javascript programming
exercise: methods 02

x
 
1
<html>
2
<script> 
3
4
var account1 = {
5
  balance: 12345.33,
6
  deposit: function(amount) {
7
    // Add code here...
8
  }
9
};
10
11
var account2 = {
12
  balance: 345.21
13
};
14
15
var account3 = {
16
  balance: 10000.00
17
};
18
19
20
// And more code here
21
22
23
24
// Code test
25
26
function test(x) {
27
  if (x)
28
    document.write("pass<br>");
29
  else
30
    document.write("FAIL<br>");  
31
}
32
33
document.write("Test Results<br>");
34
35
var value = 12345.33 + 150.00;
36
document.write("account1.balance is: "+account1.balance+" and should be: "+value+"<br>");