Skip to content

Commit e5c0dd5

Browse files
committed
modified: script/37. this.js
modified: script/39. classes.js
1 parent ab5ece3 commit e5c0dd5

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

script/37. this.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ const spongebob = {
1919
}
2020
}
2121

22+
const marcel = {
23+
nama: "Marcel",
24+
nama_lengkap: "Marcel Dita Nugraha",
25+
sayName: function(){
26+
console.log(this.nama_lengkap)
27+
},
28+
}
29+
marcel.sayName()
2230
spongebob.sayHello()
2331
spongebob.sayAgain()
2432

script/39. classes.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,28 @@ console.log(`The price is: $${product1.calculateTotal(salesTax)}`)
3232
product2.displayProduct()
3333
console.log(`The price is: $${product2.calculateTotal(salesTax)}`)
3434
product3.displayProduct()
35-
console.log(`The price is: $${product3.calculateTotal(salesTax)}`)
35+
console.log(`The price is: $${product3.calculateTotal(salesTax)}`)
36+
37+
class dataOrang{
38+
constructor(nama, alamat, pekerjaan){
39+
this.nama = nama,
40+
this.alamat = alamat,
41+
this.pekerjaan = pekerjaan
42+
}
43+
tampilkanData(){
44+
console.log("=== === === === === ===")
45+
console.log(`Namaku adalah: ${this.nama}`)
46+
console.log(`Alamat saya di ${this.alamat}`)
47+
console.log(`Pekerjaan saya adalah ${this.pekerjaan}`)
48+
}
49+
}
50+
51+
let doni = new dataOrang(
52+
window.prompt("Who are You?"),
53+
window.prompt("Where is your address?"),
54+
window.prompt("What is your occupation?")
55+
);
56+
let yanto = new dataOrang("Yanto", "Sambirejo", "Pelajar SMA");
57+
let dewi = new dataOrang("Dewi", "Ngetal", "Pelajar Mahasiswa");
58+
59+
doni.tampilkanData()

0 commit comments

Comments
 (0)