function Person(namePerson, agePerson, heightPerson,wightPerson) { //constructor name must with begin letter capital(letter Large);
this.name = namePerson.charAt(0).toUpperCase() + namePerson.substr(1);
this.age = agePerson;
this.height = heightPerson;
this.wight = wightPerson;
this.sayName = function () {
return `My name is : ${this.name}`;
};
this.bmi = function (){
return this.wight / ((this.height/100)**2);
}
this.print = function (){
let output =`my name is :${this.name}
my age is :${this.age}
height is :${this.height}CM
wight is :${this.wight}KG
BMI is :${this.bmi()}`;
return output;
}
}
var p1=new Person('mahdi',30 , 170,86);
console.log(p1.print());