Не понимаю в чем ошибка
вывод в консоль уберите. если хотели протестировать метод объекта, нужно было его вызвать в консоль так:
console.log( house.calculateSquare() );
2 лайка
Мой код
let materialPrice = {
'wood': 1000,
'stone': 1500,
'brick': 2000
};
let house = {
rooms: 10,
floors: 5,
material: 'wood',
coefficient: 10.5,
calculateSquare: function() {
let areaHouse = this.rooms * this.coefficient * this.floors;
return areaHouse;
},
calculatePrice: function() {
let priceBuilding = this.calculateSquare() * materialPrice[this.material];
return priceBuilding;
}
};
let materialPrice = {
'wood': 1000,
'stone': 1500,
'brick': 2000
};
let house = {
rooms: 1,
floors: 1,
material: 'wood',
coefficient: 1,
calculateSquare: function () {
return this['rooms'] * this['coefficient'] * this['floors']
},
calculatePrice: function () {
return this['rooms'] * this['coefficient'] * this['floors'] * materialPrice[this.material]
}
};
1 лайк
let materialPrice = {
‘wood’: 1000,
‘stone’: 1500,
‘brick’: 2000
};
let house = {
rooms: 10,
floors: 5,
material: ‘wood’,
coefficient: 10.5,
calculateSquare: function() {
let areaHouse = house.rooms * house.coefficient * house.floors;
return areaHouse;
},
calculatePrice: function() {
let priceBuildingHouse = house.calculateSquare() * materialPrice[house.material];
return priceBuildingHouse;
console.log(house[material]);
}
};