I don't know why perimeter and area property is Nan ?? can anyone explain this to me??
function Rectangle(a, b) {
return {
length:a,
width:b,
perimeter: 2 * (this.length + this.width),
area: this.length * this.width,
print(){
console.log(this.perimeter);
console.log(this.area);
}
};
}
const rect = Rectangle(10, 20);
console.log(rect);
rect.print();
output:
{
length: 10,
width: 20,
perimeter: NaN,
area: NaN,
print: [Function: print]
}