UNPKG

shivani.js

Version:

Demos for CDAC Training

28 lines (25 loc) 496 B
//anonymousModule.js module.exports = (function(){ //create the fields and the functions.. //map the functions to the object that exposes the members var list = []; function add(item){ list.push(item) } function remove(id){ for (var i = 0; i < list.length; i++) { if(list[i].id == id){ list.splice(i, 1); return; } } } function getAll(){ return list; } return{ addToCart : add, deleteFromCart : remove, getCart :getAll } })();