JSFiddle - React, Tailwind, and code Playground

by lavisha99

JavaScript

const books = [
  {
    "title": "Classic Battletech",
    "language": [
      "eng"
    ],
    "has_fulltext": false,
    "author_name": [
      "Classic Battletech"
    ],
    "cover_i": 960113,
    "isbn": [
      "1932564330",
      "9781932564570",
      "1932564578",
      "9781932564334"
    ]
  },
  {
    "title": "Western Canada (Directory of Canadian Schools)",
    "language": [
      "eng"
    ],
    "has_fulltext": false,
    "author_name": [
      "Kasher Classic"
    ],
    "isbn": [
      "9781896537429",
      "1896537421"
    ]
  }];
  
  function searchBook(isbn) {
  let BookMatch = [];
  for (let i = 0; i < books.length; i++) {
    if (books[i].isbn.includes(isbn)) {
      BookMatch.push(books[i].title);

    }
  }
  return BookMatch;
}
let result = searchBook('9781896537429');
console.log(result);