I
,RM4724 Assignment 4 (COMPLETE ANSWERS)
2024 (776400) - DUE 5 September 2024 ; 1
00% TRUSTED Co
Question 1 (30 Marks) Write a JavaScript function to add the
following books in the library collection for author John
Grisham. The number in the parentheses is the year of
publication. A Time to Kill (1989) The Firm (1991) The Pelican
Brief (1992) The Client (1993) The Chamber (1994) The
Rainmaker (1995) The Runaway Jury (1996) The Partner (1997)
The Street Lawyer (1998) The Testament (1999) The Brethren
(2000) A Painted House (2001) Skipping Christmas (2001) The
Summons (2002) The King of Torts (2003) Bleachers† (2003) The
Last Juror (2004) The Broker (2005) Playing for Pizza (2007) The
Appeal 2008) The Associate (2009) The Confession (2010) The
Litigators (2011) Calico Joe (2012) The Racketeer (2012)
Sycamore Row (2013) Gray Mountain (2014)
To add these books to a library collection using JavaScript, you
can create a function that stores the book details (title and
year) for author John Grisham. The function can push these
books into an array representing the library collection.
Here’s a sample implementation:
javascript
Copy code
// Define the library collection
const libraryCollection = [];
, // Define the function to add books
function addJohnGrishamBooks() {
// Array of John Grisham books with titles and publication
years
const books = [
{ title: "A Time to Kill", year: 1989 },
{ title: "The Firm", year: 1991 },
{ title: "The Pelican Brief", year: 1992 },
{ title: "The Client", year: 1993 },
{ title: "The Chamber", year: 1994 },
{ title: "The Rainmaker", year: 1995 },
{ title: "The Runaway Jury", year: 1996 },
{ title: "The Partner", year: 1997 },
{ title: "The Street Lawyer", year: 1998 },
{ title: "The Testament", year: 1999 },
{ title: "The Brethren", year: 2000 },
{ title: "A Painted House", year: 2001 },
{ title: "Skipping Christmas", year: 2001 },
{ title: "The Summons", year: 2002 },
,RM4724 Assignment 4 (COMPLETE ANSWERS)
2024 (776400) - DUE 5 September 2024 ; 1
00% TRUSTED Co
Question 1 (30 Marks) Write a JavaScript function to add the
following books in the library collection for author John
Grisham. The number in the parentheses is the year of
publication. A Time to Kill (1989) The Firm (1991) The Pelican
Brief (1992) The Client (1993) The Chamber (1994) The
Rainmaker (1995) The Runaway Jury (1996) The Partner (1997)
The Street Lawyer (1998) The Testament (1999) The Brethren
(2000) A Painted House (2001) Skipping Christmas (2001) The
Summons (2002) The King of Torts (2003) Bleachers† (2003) The
Last Juror (2004) The Broker (2005) Playing for Pizza (2007) The
Appeal 2008) The Associate (2009) The Confession (2010) The
Litigators (2011) Calico Joe (2012) The Racketeer (2012)
Sycamore Row (2013) Gray Mountain (2014)
To add these books to a library collection using JavaScript, you
can create a function that stores the book details (title and
year) for author John Grisham. The function can push these
books into an array representing the library collection.
Here’s a sample implementation:
javascript
Copy code
// Define the library collection
const libraryCollection = [];
, // Define the function to add books
function addJohnGrishamBooks() {
// Array of John Grisham books with titles and publication
years
const books = [
{ title: "A Time to Kill", year: 1989 },
{ title: "The Firm", year: 1991 },
{ title: "The Pelican Brief", year: 1992 },
{ title: "The Client", year: 1993 },
{ title: "The Chamber", year: 1994 },
{ title: "The Rainmaker", year: 1995 },
{ title: "The Runaway Jury", year: 1996 },
{ title: "The Partner", year: 1997 },
{ title: "The Street Lawyer", year: 1998 },
{ title: "The Testament", year: 1999 },
{ title: "The Brethren", year: 2000 },
{ title: "A Painted House", year: 2001 },
{ title: "Skipping Christmas", year: 2001 },
{ title: "The Summons", year: 2002 },