Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions exercises/57 - Shopping List/shopping-FINISHED.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,17 @@ function displayItems() {
.map(
item => `<li class="shopping-item">
<input
id="item-${item.id}"
value="${item.id}"
type="checkbox"
${item.complete && 'checked'}
>
name="item-${item.id}"
${item.complete ? 'checked' : ''}
/>
<span class="itemName">${item.name}</span>
<button
aria-label="Remove ${item.name}"
value="${item.id}"
>&times;</buttonaria-label="Remove>
>&times;</button>
</li>`
)
.join('');
Expand All @@ -54,18 +56,15 @@ function mirrorToLocalStorage() {
function restoreFromLocalStorage() {
console.info('Restoring from LS');
// pull the items from LS
const lsItems = JSON.parse(localStorage.getItem('items'));
const lsItems = JSON.parse(localStorage.getItem('items')) || [];
if (lsItems.length) {
// items = lsItems;
// lsItems.forEach(item => items.push(item));
// items.push(lsItems[0], lsItems[1]);
items.push(...lsItems);
items = lsItems;
list.dispatchEvent(new CustomEvent('itemsUpdated'));
}
}

function deleteItem(id) {
console.log('DELETIENG ITEM', id);
console.log('DELETING ITEM', id);
// update our items array without this one
items = items.filter(item => item.id !== id);
console.log(items);
Expand Down
2 changes: 1 addition & 1 deletion exercises/76 - Dad Jokes/index-FINISHED.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
</button>
</div>

<script src="./jokes.js"></script>
<script src="./jokes-FINISHED.js"></script>
</body>

</html>
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.