Reputation: 9
var paper=new Object();
paper.color="red";
paper.height= function(a+b){
return a+b;
}
document.write(paper.height(10,11));
Why's this not working? Someone please explain..
Upvotes: 0
Views: 40
Reputation: 6436
function(a+b) should be function(a, b)
var paper = {};
paper.color = "red";
paper.height = function(a, b) {
return a + b;
}
document.write(paper.height(10, 11));
Upvotes: 0
Reputation: 2394
Your function definition is incorrect. "a+b" isn't valid for arguments, you need to comma separate them:
paper.height = function(a,b) { return a + b; };
Upvotes: 1