File tree Expand file tree Collapse file tree 2 files changed +41
-1
lines changed Expand file tree Collapse file tree 2 files changed +41
-1
lines changed Original file line number Diff line number Diff line change 10
10
< button > click me!</ button >
11
11
<!-- <script src="./task1.js"></script> -->
12
12
<!-- <script src="./task2.js"></script> -->
13
- < script src ="./task3.js "> </ script >
13
+ <!-- <script src="./task3.js"></script> -->
14
+ < script src ="./task4.js "> </ script >
14
15
</ body >
15
16
</ html >
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Keep track of which books you read and which books you want to read!
3
+ *
4
+ * Follow the steps:
5
+ * Declare a variable that holds an array of 3 objects, where each object describes a book and
6
+ * has properties for the title (string), author (string), and
7
+ * alreadyRead (boolean indicating if you read it yet).
8
+ * Loop through the array of books.
9
+ * For each book, log the book title and book author like so: "The Hobbit by J.R.R. Tolkien".
10
+ * Create a conditional statement to change the log depending on whether you read it yet or not.
11
+ * If you read it, log a string like You already read "The Hobbit" right after the log of the book details
12
+ * If you haven't read it log a string like You still need to read "The Lord of the Rings"
13
+ */
14
+
15
+ const books = [
16
+ {
17
+ title : 'The Hobbit' ,
18
+ author : '"J.R.R. Tolkien"' ,
19
+ alreadyRead : true ,
20
+ } ,
21
+ {
22
+ title : 'The Lord of the Rings' ,
23
+ author : '"J.R.R. Tolkien"' ,
24
+ alreadyRead : true ,
25
+ } ,
26
+ {
27
+ title : 'JavaScript: The Definitive Guide' ,
28
+ author : 'Devid FLENAGAN' ,
29
+ alreadyRead : false ,
30
+ } ,
31
+ ] ;
32
+
33
+ const Message = books . map ( ( book ) => {
34
+ if ( book . alreadyRead === true ) {
35
+ console . log ( `You already read ${ book . title } ` ) ;
36
+ } else {
37
+ console . log ( `You still need to read ${ book . title } ` ) ;
38
+ }
39
+ } ) ;
You can’t perform that action at this time.
0 commit comments