1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
IRINA_888 [86]
3 years ago
5

Write a function searchBooks which returns ALL the books written by a specific author and return the list of the book titles as

a string, separated with comma if there are more than one titles. If these is no author in the library then return 'NOT FOUND'. Example dataset: library = [ { author: 'Bill Gates', title: 'The Road Ahead', libraryID: 1254} ];.
Computers and Technology
1 answer:
dalvyx [7]3 years ago
4 0

Answer:

var library=[{author:'Bill Gates',title:'The Road Ahead',libraryID:1254},

              {author:'Abdul Kalam',title:'India 2020',libraryID:1243},

              {author:'Abdul Kalam',title:'Ignited Minds',libraryID:1200},

              {author:'Abdul Kalam',title:'Inspiring thoughts',libraryID:1200},

              {author:'Aristotle',title:'Metaphysics',libraryID:1200}

              ];

  //author of the book to be searched

  var authorName='Abdul Kalam';

  //document.write() will write in the html page

  a=searchBooks(library,authorName);

  books=a[0];

  authorNames=a[1];

  //<h1></h1> is used to make heading Books

  document.write("Books:\n");

  for(i=0;i<books.length;i++)

      document.write(books[i]['author']+" --> "+books[i]['title']+" --> "+books[i]['libraryID']+"<br>");

  document.write("Titles:\n"+a[1]);

  function searchBooks(library,authorName){

      //empty string to assign book names

      list_of_titles='';

      books=[];

      //reading each book from 0th position to last

      for(i=0;i<library.length;i++){

          //if author is authorName then add it to list_of_titles

          if(library[i]['author']==authorName){

              books.push(library[i]);

              list_of_titles+=library[i]['title']+",";

          }

      }

      //removing the last comma

      list_of_titles=list_of_titles.slice(0,-1);

      //if list_of_titles is empty return NOTFOUND

      if(list_of_titles=='')

          return 'NOT FOUND';

      //if books are found return list_of_titles

      else

          return [books,list_of_titles];

      //returning the list of books and titles

  }

You might be interested in
Which of these statements is true about database reports? A. A generated report will include all records in the database. B. A g
weeeeeb [17]

B. A generated report will include all records that a query fetches.

6 0
3 years ago
A customer in Lowe's needs help. Matt works in shipping and receiving. It isn't Matt job to work with the customer, but he knows
klio [65]

Answer:

40

Explanation:

hhhhhjjjj

5 0
3 years ago
Read 2 more answers
100 POINTS + BRAINLYEST TO FIRST PERSON THAT IS CORRECT!!! Tomika wants to create a cell style for her workbook and share it wit
andrew11 [14]

Answer:

Go to the Home tab on the ribbon and the group Styles.

Left Click Cell Styles, then click New Cell Style and create the style.

To share it with other workbooks, use the Merge Styles function in the same group.

Explanation:

This info was for excel.

Please mark brainliest!

6 0
3 years ago
Read 2 more answers
A database stores a large amount data in vertical ___
myrzilka [38]

Records for the first one and table for the second one

4 0
4 years ago
Identify the following verb by number and person by checking on the appropriate boxes.
Makovka662 [10]
Second person ig Imao yeah
3 0
3 years ago
Read 2 more answers
Other questions:
  • strategy that is used to help improve the chances that your site will be found by search engines is known as search engine
    12·1 answer
  • Which term refers to actions that you would typically perform on a computer to revive it if it functions in an unexpected manner
    15·2 answers
  • Universal Container sales reps can modify fields on an opportunity until it is closed. Only the sales operations team can modify
    13·1 answer
  • You are trying to troubleshoot a desktop power supply issue using a voltmeter. Which of the following options are the MOST commo
    6·1 answer
  • Worth 30 pts
    9·2 answers
  • Is there any difference beetween the old version of spyro released on the origional and the newer ones??? or is it only change i
    8·1 answer
  • Why are formulas used in spreadsheets?
    10·1 answer
  • Five uses of the operating system​
    10·2 answers
  • What is data science?​
    15·1 answer
  • Which code block is an example of a motion block in scratch?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!