function friendliestAuthor(authors) {
  // Your code goes here
  let copyAuthor = authors;
  copyAuthor.forEach((author) => (author["repeat"] = 0));
  // for (let index = 0; index < authors.length; index++) {
  //   for (let index1 = 0; index1 < authors.length; index1++) {
  //     copyAuthor[index][repeat] += compareArrays(
  //       copyAuthor[index].books,
  //       copyAuthor[index1].books
  //     );
  //   }
  // }
  copyAuthor.forEach((author) => {
    for (let index = 0; index < authors.length; index++) {
      author["repeat"] += compareArrays(author.books, authors[index].books);
    }
  });
  let max = 0;
  let bestOne = 0;
  copyAuthor.forEach((author) => {
    if (author.repeat > max) {
      max = author.repeat;
      bestOne = author;
      // bestOne = authorObj.author;
    }
  });

  return bestOne.name;
}
/**************************************************************
 * friendliestAuthor(authors):
 * - receives a list of authors
 * - returns the name of the author that has
 *   co-authored the greatest number of books
 ****************************************************************/
- receives a list of authors
- returns the name of the author that has
co-authored the greatest number of books
- receives a list of authors - returns the name of the author that has co - authored the greatest number of books
function friendliestAuthor(authors) {
  let copyAuthor = authors;
  copyAuthor.forEach((author) => (author["repeat"] = 0));
  copyAuthor.forEach((author) => {
    for (let index = 0; index < authors.length; index++) {
      author["repeat"] += compareArrays(author.books, authors[index].books);
    }
  });
  let max = 0;
  let bestOne = 0;
  copyAuthor.forEach((author) => {
    if (author.repeat > max) {
      max = author.repeat;
      bestOne = author;
    }
  });
  return bestOne.name;
}
function friendliestAuthor ( authors ) { let copyAuthor = authors ; copyAuthor . forEach ( ( author ) => ( author [ "repeat" ] = 0 ) ) ; copyAuthor . forEach ( ( author ) => { for ( let index = 0 ; index < authors . length ; index ++ ) { author [ "repeat" ] += compareArrays ( author . books , authors [ index ] . books ) ; } } ) ; let max = 0 ; let bestOne = 0 ; copyAuthor . forEach ( ( author ) => { if ( author . repeat > max ) { max = author . repeat ; bestOne = author ; } } ) ; return bestOne . name ; }
friendliestAuthor(authors):
 - receives a list of authors
 - returns the name of the author that has
   co-authored the greatest number of books
friendliestAuthor ( authors ) : - receives a list of authors - returns the name of the author that has co - authored the greatest number of books
// Your code goes here // for (let index = 0; index < authors.length; index++) { //   for (let index1 = 0; index1 < authors.length; index1++) { //     copyAuthor[index][repeat] += compareArrays( //       copyAuthor[index].books, //       copyAuthor[index1].books //     ); //   } // } // bestOne = authorObj.author;