From 8c54b05889e2b4c47ee85bf2a8462cdb881f2045 Mon Sep 17 00:00:00 2001 From: fatima safana Date: Wed, 1 Jan 2025 14:20:31 +0000 Subject: [PATCH] implemented requirement for reading list --- .../{index.html => Reading-list-app.html} | 0 Sprint-3/reading-list/script.js | 29 +++++++++++++++++++ 2 files changed, 29 insertions(+) rename Sprint-3/reading-list/{index.html => Reading-list-app.html} (100%) diff --git a/Sprint-3/reading-list/index.html b/Sprint-3/reading-list/Reading-list-app.html similarity index 100% rename from Sprint-3/reading-list/index.html rename to Sprint-3/reading-list/Reading-list-app.html diff --git a/Sprint-3/reading-list/script.js b/Sprint-3/reading-list/script.js index 6024d73a..661b2fcd 100644 --- a/Sprint-3/reading-list/script.js +++ b/Sprint-3/reading-list/script.js @@ -21,3 +21,32 @@ const books = [ }, ]; + +//1: get elements +const readingList = document.querySelector("#reading-list"); + +//2: display LIST OF BOOKS + books.forEach((book) => { + let listItem = document.createElement("li") + listItem.innerHTML = ` +

${book.title}

by ${book.author} +
+ ${book.title}cover + `; + //if alreadyRead is true set background color to green else to red + if(book.alreadyRead){ + listItem.style.backgroundColor = "green" + }else { + listItem.style.backgroundColor = "red" + } + // add each list element + readingList.appendChild(listItem); + + }); + + + + + + +