Write a JavaScript function to find ALL the books in a 'library' written by a specific author.
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 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'