Members
buttonsDOM
array of buttons objects represents buttons.btn-bag
- note "those buttons created and populated into DOM using javascript"
cart
array of cartItem objects represents products was added to cart
constant cartContent
assigning div.cart-content html DOM element to cartContent object
constant cartItems
assigning div.cart-items html DOM element to cartItems object
constant cartOverlay
assigning div.overlay DOM to cartOverlay object
constant cartTotal
assigning span.cart-total html DOM element to cartTotal object
constant clearBtn
assigning button.clear-cart DOM to clearBtn object
constant client
external api provied demo data for testing or populating the UI
constant closeCartBtn
assigning div.close-cart DOM to closeCartBtn object
constant productsDOM
assigning div.products-center html DOM element to productsDOM object
Methods
displayProducts(products)
takes an array of products and populate the DOM
Parameters:
Name | Type | Description |
---|---|---|
products |
Array.<Objects> | to be displayed |
inner getCart() → {Array.<Object>}
reading (fetching) cartItems array cart from the browser local storage
Parameters:
Type | Description |
---|---|
Array.<Object> |
cart
Example
Storage.getCart()
async inner getProducts() → {Array.<Object>}
fetching and destructuring items(products) then assigning them to an array of product object
[] [array of product object]
Example
products.getProducts();
inner getProducts(id) → {Object}
reading products from the browser localt storage takes the id of product as a parameter and returns product matches that array
Parameters:
Name | Type | Description |
---|---|---|
id |
number | of item to be fetched |
Example
Storage.getProducts(1);
map array higher order function(function) → {Array.<Object>}
destructuring items from the array then reassign as
Parameters:
Name | Type | Description |
---|---|---|
function |
inner saveCart(cart)
saving cartItems array in the browser local storage takes the cart items array as a parameter
Parameters:
Name | Type | Description |
---|---|---|
cart |
Array.<Object> | items cartItems to be saved |
Example
Storage.saveCart(cart)
inner saveProducts(pruducts)
saving products in the browser localt storage takes products array as a parameter products
Parameters:
Name | Type | Description |
---|---|---|
pruducts |
Array.<Object> | to be saved |
Example
Storage.saveProducts(products);