-
Notifications
You must be signed in to change notification settings - Fork 0
/
appes6.html
62 lines (53 loc) · 1.47 KB
/
appes6.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>ES 6</title>
</head>
<body>
<div id="app"></div>
<script>
// Class
class Client {
// to the constructor
constructor(name, balance) {
this.name = name;
this.balance = balance;
}
membership() {
let name;
//check for the balance
if (this.balance > 1000) {
name = 'Gold';
} else if (this.balance > 500) {
name = 'Platinum';
} else {
name = 'Normal';
}
return name;
}
clientInfo() {
return `Name: ${this.name}, Balance: ${this.balance},
Membership: ${this.membership()}`
}
withdraw(amount) {
this.balance -= amount;
}
getBalance(){
return this.balance;
}
// static method doesn't require instaciation
static welcome(){
return 'Welcome to your bank';
}
}
const mary = new Client('Mary', 1000);
console.log(mary);
console.log(mary.clientInfo());
console.log(mary.membership());
mary.withdraw(500);
console.log(mary.clientInfo());
console.log(Client.welcome());
</script>
</body>
</html>