Created
September 20, 2022 20:08
-
-
Save giovannamoeller/1e3a60a535a32b1c159abb17fceb469e to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Person { | |
| constructor(name, height, weight, age) { | |
| this.name = name; | |
| this.height = height; | |
| this.weight = weight; | |
| this.age = age; | |
| } | |
| getAge() { | |
| return this.age; | |
| } | |
| setAge(age) { | |
| this.age = age; | |
| } | |
| calculateIMC() { | |
| return this.weight / (this.height * this.height); | |
| } | |
| } | |
| const person1 = new Person('John', 1.86, 78, 34); | |
| const person1Age = person1.getAge(); // 34 | |
| const person1IMC = person1.calculateIMC(); // 22.5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment