Question: Write a JavaScript function to find ALL the books in a 'library' written by a specific author. You should return: The list of the book

Write a JavaScript function to find ALL the books in a 'library' written by a specific author. You should return:

The list of the book titles as a string, with titles separated by a comma; OR

'NOT FOUND' if there is no match.

Note that there should be no trailing comma and no additional space(s) surrounding the comma(s) - see the examples below for details.

Example dataset, input and expected output:

library = [

   { author: 'Bill Gates', title: 'The Road Ahead', libraryID: 1254},

   { author: 'Carolann Camilo', title: 'Eyewitness', libraryID: 32456},

   { author: 'Carolann Camilo', title: 'Cocky Marine', libraryID: 32457} 

  ];

Input: [library, 'Bill Gates']

Expected Output: 'The Road Ahead'

Input: [library, 'Carolann Camilo']

Expected Output: 'Eyewitness,Cocky Marine'

Input: [library, 'Lala']

Expected Output: 'NOT FOUND'

Step by Step Solution

3.44 Rating (154 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

processstdinresume processstdinsetEncodingutf8 Your code here var myMap new Map library author ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Chemical Engineering Questions!