Created
November 22, 2011 13:19
-
-
Save gipi/1385644 to your computer and use it in GitHub Desktop.
Create a module in Javaascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var basketModule = (function() { | |
var basket = []; //private | |
return { //exposed to public | |
addItem: function(values) { | |
basket.push(values); | |
}, | |
getItemCount: function() { | |
return basket.length; | |
}, | |
getTotal: function(){ | |
var q = this.getItemCount(),p=0; | |
while(q--){ | |
p+= basket[q].price; | |
} | |
return p; | |
} | |
} | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment