Quotes help make search much faster. Example: "Practice Makes Perfect"

Thursday, December 6, 2012

Codecademy: Codeyear Functions: Accomplished and Returned


//sample solution


var MathObject = {
    val: 42,
   
    setVal: function(newVal){
        this.val = newVal;
    },
    getVal: function(){
        return this.val;
    },
    getSqrVal: function(){
        this.val = this.val * this.val;
        return this.val;
    },
    getValplusplus: function(){
        this.val++;
        return this.val;
    },
    getValplusN: function(N){
        this.val+=N;
        return this.val;
    }
};

//test
console.log(MathObject.getValplusN(8));

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts