Skip to content Skip to sidebar Skip to footer

Is It Possible To Have A Javascript Variable To Have Two Or More Functions Inside?

I have the following Javascript code: var Lab = { minseat: function(){ var seat = 10; return seat; } maxseat: function(){

Solution 1:

You forgot a comma after the first function:

varLab = {
    minseat: function(){
        var seat = 10;
        return seat;
    },

    maxseat: function(){
        var seat = 50;
        return seat;
    }

 }

Solution 2:

How about a comma separating the keys in your object definition.

varLab = {
        minseat: function(){
            var seat = 10;
            return seat;
        },
        maxseat: function(){
            var seat = 50;
            return seat;
        }

     }

http://jsfiddle.net/V4Yje/

Post a Comment for "Is It Possible To Have A Javascript Variable To Have Two Or More Functions Inside?"