Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c94511d

Browse files
task4
1 parent 1fe8834 commit c94511d

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

my-node-server/public/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<button>click me!</button>
1111
<!-- <script src="./task1.js"></script> -->
1212
<!-- <script src="./task2.js"></script> -->
13-
<script src="./task3.js"></script>
13+
<!-- <script src="./task3.js"></script> -->
14+
<script src="./task4.js"></script>
1415
</body>
1516
</html>

my-node-server/public/task4.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
});

0 commit comments

Comments
 (0)