function Person(name, age, height, weight, sex, hairColor, BMI) {
this.name = name;
this.age = age;
this.height = function () {
return height / 100;
};
this.weight = weight;
this.sex = sex;
this.hairColor = hairColor;
this.sayName = function () {
return 'Your name is ' + nameUpperCase(this.name);
}
}
function nameUpperCase(str) {
return str[0].toUpperCase() + str.slice(1);
}
let x = new Person(prompt("What's your name?"), prompt('How old are you ?'), prompt("How tall are you ?"), prompt("What's your weight ?"), prompt("What's your sex ?"), prompt("What's your hair color ?"));
console.log(x.sayName(), ` ,you're ${x.age} years old,`, `you're height is ${x.height() + "m"},`, `you're weight is ${x.weight},`, `you're sex is ${x.sex},`, `you're color is ${x.hairColor}`);
let heiGht = x.height();
let weiGht = x.weight;
console.log("your height is : " + heiGht + " m" );
console.log("your weight is : " + weiGht + " kg" );
let BMI = Math.ceil(weiGht / Math.pow(heiGht,2));
console.log("you're BMI is : " + BMI );
سلام
وقت به خیر
شما از امکانات و مزیتهای کلاس استفاده نکردید
دو تابع مجزا نوشتید که عملا ربطی به مفاهیم تدریس شده نداره
از طرفی نوشتن کد به شکلی که در دو خط بعد از تابع nameUpperCase نوشتید اشتباهه. خطا نمیده ولی استاندارد نیست. کد را به طور کامل بازبینی کنید