Skip to content

Instantly share code, notes, and snippets.

@giovannamoeller
Created September 20, 2022 20:08
Show Gist options
  • Select an option

  • Save giovannamoeller/1e3a60a535a32b1c159abb17fceb469e to your computer and use it in GitHub Desktop.

Select an option

Save giovannamoeller/1e3a60a535a32b1c159abb17fceb469e to your computer and use it in GitHub Desktop.
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