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
33 lines (22 loc) · 603 Bytes
/
app.js
File metadata and controls
33 lines (22 loc) · 603 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
26
27
28
29
30
31
32
33
console.log("Hello World!\n==========\n");
// Exercise 1 Section
console.log("EXERCISE 1:\n==========\n");
const numbers = [2, 22, 12, 17, 18, 39, 129];
function arraySum(numbers) {
let sum = 0;
numbers.forEach((number, index) => {
sum += number;
});
return sum;
}
console.log(arraySum(numbers));
// Exercise 2 Section
console.log("EXERCISE 2:\n==========\n");
let book = {};
book.title = "Name of the Wind";
book.pages = 722;
book.readCount = 5;
book.info = function () {
return `${this.title}, ${this.pages} pages, read ${this.readCount} times.`;
};
console.log(book.info());