var elka = {
storage: [],
displayStorage: function() {
if (this.storage.length === 0) {
console.log('You Should put numbers!');
} else {
console.log('Youre result is: ');
for (var i = 0; i < this.storage.length; i++) {
console.log(this.storage[i]);
}
}
},
add: function(numOne, numTwo) {
result = numOne + numTwo;
this.storage.push(result);
this.displayStorage();
},
devide: function(numOne, numTwo) {
result = numOne - numTwo;
this.storage.push(result);
this.displayStorage();
},
multiplication: function(numOne, numTwo) {
result = numOne * numTwo;
this.storage.push(result);
this.displayStorage();
},
division: function(numOne, numTwo) {
result = numOne / numTwo;
this.storage.push(result);
this.displayStorage();
}
};
这是我的代码 当我尝试从Oject调用一个函数 - 这是一个例子“elka.add(12,23)”,我得到的公告是 未捕获的ReferenceError:未定义elka at:1:1 我一直在徘徊代码,并试图修复语法错误,但我仍然得到这个按摩,我不知道我搞砸了什么。提前致谢 ! :)