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();

1 Answer 1

2

Convert this

 this.updateInventory;

to this

 this.updateInventory();

DEMO

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

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.