forked from truecodersio/JavaScript_Objects_Arrays
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
25 lines (22 loc) · 642 Bytes
/
app.js
File metadata and controls
25 lines (22 loc) · 642 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
console.log("Hello World!\n==========\n");
// Exercise 1 Section
console.log("EXERCISE 1:\n==========\n");
const numbers = [2, 22, 12, 17, 18, 39, 129];
const arraySum = (numbers) => {
let sum = 0;
numbers.forEach((num) => {
sum += num;
});
return sum;
};
console.log(arraySum(numbers));
// Exercise 2 Section
console.log("EXERCISE 2:\n==========\n");
const book = {};
book.title = "Lord Of The Rings: The Fellowship Of The Ring by J.R.R Tolkien";
book.pages = 458;
book.readCount = 1;
book.info = () => {
return `${book.title}, ${book.pages} pages, Read ${book.readCount} times.`;
};
console.log(book.info());