answer.
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]
2 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]2 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
Zoey has brought her computer in for servicing. When she dropped off her computer, she mentioned that her computer will sometime
galina1969 [7]

Answer:

Option (B) Overheated CPU

Explanation:

  • The above problems mentioned are due to the problem with the CPU.
  • Overheated CPU can result into freezing the computer and unexpected rebooting.
  • CPU stands for Central Processing Unit and is responsible for all the instabilities in the hardware parts of the computer.
  • So, option (b) is true.
  • A Network Card is responsible for connecting the computer to the internet. It also has other names like Ethernet Card. A bad Network Card results in problems with the internet and network connections but not the above problems. So, option (A) is false.
  • UPS is Uninterrupted Power Supply. It is an external power device to provide the power supply to the computers in case of emergencies to not shut down the computer instantaneously. The above problems are not likely to be the caused by the failed UPS. So, option (C) is false.
  • Drive is a hardware device to store information. It can be removable drive (optical drives like CDs, DVDs ) or non removable like ( Hard Disk Drive ). A failed drive results in problems with the storing information. The above problems are not associated with it. So, option (D) is also false.
6 0
2 years ago
Read 2 more answers
Write a loop that counts the number of space characters in a string. Recall that the space character is represented as ' '.
Jlenok [28]

Answer:

I am writing Python program.

string = input("Enter a string: ")

print(string.count(' '))

Explanation:

The first statement takes input string from the user.

input() is used to read the input from the user.

The next statement uses count() function to count the number of times the specified object which is space ' ' here occurs in the string.

The print() function is used to return the number of times the space occurs in the string entered by the user.

Output:

Enter a string: How are you doing today?

4

The screenshot of program and its output is attached.

3 0
2 years ago
Which of the given assertion methods will return true for the code given below? Student student1 = new Student(); Student studen
Svetradugi [14.3K]

Answer:

The true statements are :

A. assertEquals(student1,student2)  

C. assertSame(student1,student3)

Explanation:

AssertEquals() asserts that the objects are equal, but assertSame() asserts that the passed two objects refer to the same object or not, if found same they return true, else return false.

6 0
2 years ago
Match each scenario to the absolute value expression that describes it. 1. the distance moved when going backwards five spaces i
soldi70 [24.7K]

Answer:

i don tunderstand the question

Explanation:

4 0
2 years ago
Read 2 more answers
Explain why types of technology valued can vary
Viefleur [7K]
Types of technology valued can vary because all technology is unique to its category so to speak. you have to realize a fork is a former of technology. just as much as a microwave is
6 0
2 years ago
Read 2 more answers
Other questions:
  • A two-dimensional array can have elements of ________ data type(s).
    7·1 answer
  • You complete your database, and the company begins using it. Shortly afterwards, two GearUp buyers, Cora and Owen, work together
    9·1 answer
  • Desmond works in Power, Structural, and Technical Systems. He would most likely be employed by
    5·2 answers
  • When configuring a record type, an App Builder can configure the available value of a picklist field for the page layout. Which
    9·1 answer
  • 1.2.2: Output variable value. Jump to level 1 Write a statement that outputs variable userAge. End with a newline. 1 2 3 4 5 6 7
    12·1 answer
  • The effectiveness of a(n) _____ process is essential to ensure the success of a data warehouse. Select one: a. visual basic b. e
    15·2 answers
  • Write the state of the elements of each of the following arrays after each pass of the outermost loop of the selection sort algo
    11·1 answer
  • Write a while loop that prints usernum divided by 2 until user_num is less than 1. The value of user_num changes inside of the l
    14·1 answer
  • _____ is a markup language designed to transport and store data on the Web. Group of answer choices Standard Generalized Markup
    13·1 answer
  • C++
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!