-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
42 lines (34 loc) · 841 Bytes
/
index.js
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
const formatter = new Intl.NumberFormat("id-ID", {
style: "currency",
currency: "IDR"
})
class Human {
constructor(name = "Unknown", age = 0, status = "Single") {
this.name = name
this.age = age
this.status = status
}
getName() {
return this.name
}
getNameAndAge() {
return `${this.name} is ${this.age} years old`
}
}
class Employee extends Human {
constructor(name, age, profession, salary) {
super(name, age)
this.profession = profession
this.salary = salary
}
getSalary() {
return `${formatter.format(this.salary)}`
}
updateSalary(newSalary) {
this.salary = newSalary
}
}
const gatot = new Employee("Gatot Lagi", 21, "Developer", 9000000)
const ipul = new Employee("Ipul", 26, "Programmer", 12000000)
gatot.updateSalary(120000000)
console.log(gatot.getSalary())