0

I'm having trouble calling a method from within another method of the same object.

Any help on what I may be missing, or what to look for, would be greatly appreciated.

var IceCream = function (flavor) {
 this.tub = 100;
 this.flavor = flavor;
};
IceCream.prototype = { 
 scoop : function () {
 this.updateInventory; alert("scooping");
 },
 updateInventory : function () {
 this.tub --;
 alert(this.tub);
 }
};
 var vanilla = new IceCream("vanilla");
 vanilla.scoop();
asked Jan 11, 2016 at 4:24

1 Answer 1

2

Convert this

 this.updateInventory;

to this

 this.updateInventory();

DEMO

answered Jan 11, 2016 at 4:27
Sign up to request clarification or add additional context in comments.

3 Comments

you just 30 seconds fater than me, sigh
glad to know :P i am the rabbit here :P @KevinSimple
ah damn, what an easy one! Thanks a lot @Anik

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.