modularize localStorage calls into localStorage.js in preparation for unit testing

This commit is contained in:
Arthur Lu
2022-11-18 07:13:53 +00:00
parent 35f44049a2
commit 6493fbd171
4 changed files with 139 additions and 108 deletions

View File

@@ -1,12 +1,12 @@
// main.js
import {getReviewsFromStorage, saveReviewsToStorage} from "./localStorage.js";
import {getAllReviewsFromStorage} from "./localStorage.js";
// Run the init() function when the page has loaded
window.addEventListener("DOMContentLoaded", init);
function init() {
// Get the reviews from localStorage
let reviews = getReviewsFromStorage();
let reviews = getAllReviewsFromStorage();
// Add each reviews to the <main> element
addReviewsToDocument(reviews);
// Add the event listeners to the form elements