Last active
December 22, 2020 07:32
-
-
Save mathdroid/3ced7c5640a263952b5d43c7c56e4a4b to your computer and use it in GitHub Desktop.
class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Human { | |
constructor(arg1, arg2) { | |
this.name = arg1; | |
this.age = arg2; | |
} | |
login() { | |
console.log("logging in"); | |
} | |
talk() { | |
console.log("hi there"); | |
} | |
isTelkomsel() { | |
// return true apabila name bukan Odi | |
return this.name !== "Odi"; | |
} | |
updateAge(newAge) { | |
this.age = newAge; | |
} | |
} | |
const odi = new Human("Odi", 5); | |
const amz = new Human("Amzar", 15); | |
const faj = new Human("Fajri", 25); | |
const dia = new Human("Diana", 35); | |
console.log(faj.isTelkomsel()); | |
console.log(odi.isTelkomsel()); | |
console.log(amz.age); | |
amz.updateAge(30); | |
console.log(amz.age); | |
// odi.walk(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment