function Person(name, age, height, weight){
this.name = name.charAt(0).toUpperCase()+name.slice(1);
this.ageEL = age;
this.heightEL = height;
this.weightEL = weight;
this.sayName = function(){
return "my name is: "+ this.name;
}
this.BMI = function(){
return bmi = this.weightEL / ((this.heightEL/100)**2);
}
}
let person1 = new Person('sasan', 20, 180, 80);
function print(variable){
console.log(variable.sayName());
console.log('age: '+variable.age);
console.log('weight: '+ variable.weight);
console.log('heigth: '+variable.height);
console.log('BMI: '+variable.BMI());
}
print(person1);
البته میدونم که میتونستم تابع پرینت رو مانند بقیه توابع مانند BMI و sayName داخل تابع Person هم تعریف کنم و مانند یک متد داخل آن بنویسم اما میخواستم این مدلی تست اش کنم