Advertisement
Guest User

Untitled

a guest
Apr 19th, 2015
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. var List = function(){
  2. this.data = [];
  3. this.add = add;
  4. this.remove = remove;
  5. this.count = count;
  6. }
  7.  
  8. function add(item){
  9. this.data.push(item);
  10. }
  11.  
  12. function remove(item){
  13. for(var i = 0; i < this.data.length; i++){
  14. if(this.data[i] === item){
  15. return this.data.splice(i, 1);
  16. }
  17. }
  18. }
  19.  
  20. function count(){
  21. return this.data.length;
  22. }
  23.  
  24. module.exports = List;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement