MCPcopy Create free account
hub / github.com/SuperSimpleDev/javascript-course / loadFromStorage

Function loadFromStorage

2-copy-of-code/lesson-18/data/cart.js:5–19  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3loadFromStorage();
4
5export function loadFromStorage() {
6 cart = JSON.parse(localStorage.getItem('cart'));
7
8 if (!cart) {
9 cart = [{
10 productId: 'e43638ce-6aa0-4b85-b27f-e1d07eb678c6',
11 quantity: 2,
12 deliveryOptionId: '1'
13 }, {
14 productId: '15b6fc6f-327a-4ec4-896f-486349e85a3d',
15 quantity: 1,
16 deliveryOptionId: '2'
17 }];
18 }
19}
20
21function saveToStorage() {
22 localStorage.setItem('cart', JSON.stringify(cart));

Callers 3

cartTest.jsFile · 0.90
cart.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected