File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -13,4 +13,27 @@ console.log(book);
13
13
// Task 2: Access and log the `title` and `author` properties of the book object.
14
14
15
15
console . log ( "The title of the Book is:- " + book . title ) ;
16
- console . log ( "The author of the book is:- " + book . author ) ;
16
+ console . log ( "The author of the book is:- " + book . author ) ;
17
+
18
+ console . log ( "-------------------------------------------------" ) ;
19
+ console . log ( "Activity 2: " ) ;
20
+
21
+ // Task 3: Add a method to the book object that returns a string with the book's title and author, and log the result of calling this method.
22
+
23
+ book . bookDetails = function ( ) {
24
+ return `The book ${ this . title } is written by ${ this . author } .` ;
25
+ } ;
26
+
27
+ console . log ( book . bookDetails ( ) ) ;
28
+
29
+ // Task 4: Add a method to the book object that takes a parameter (year) and updates the book's year property, then log the updated object.
30
+
31
+ book . updateYear = function ( year ) {
32
+ this . year = year ;
33
+ return this ;
34
+ } ;
35
+
36
+ console . log ( book . updateYear ( "2021" ) ) ;
37
+
38
+ console . log ( "-------------------------------------------------" ) ;
39
+ console . log ( "Activity 3: " ) ;
You can’t perform that action at this time.
0 commit comments