-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbank-objects.html
More file actions
66 lines (51 loc) · 1.14 KB
/
bank-objects.html
File metadata and controls
66 lines (51 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script>
function isValidNumber(amount){
if(isNaN(amount)){
return false;
}else{
return true;
}
}
var depositFx = function (amount){
if(isValidNumber(amount)){
this.balance = this.balance + amount;
return;
}
return "This is not a valid number";
}
var withdrawFx = function(amount){
if(isValidNumber(amount)){
if(amount > this.balance){
return "You don't enough money";
}
this.balance -= amount;
return;
}else{
return "This is not a valid number";
}
}
// Checking account
var checkingAccount = {
balance: 0,
accountNumber: 12345,
owner: "Fer",
deposit: depositFx,
withdraw: withdrawFx
};
var savingsAccount = {
balance: 500,
accountNumber: 54321,
owner: "Fer",
deposit: depositFx,
withdraw: withdrawFx
};
</script>
</body>
</html>