JSFiddle - React, Tailwind, and code Playground

by nevkatz

HTML

<div id="highlighted-book">

</div>

JavaScript

function printBook({bookId, lastName, firstName, bookTitle, bookDate}) {
  let el = document.getElementById('highlighted-book');
  
  el.textContent = `${lastName}, ${firstName}. ${bookDate}. ${bookTitle}. ID: ${bookId}`;
}


let book = {
  bookId:'0865305404',
  lastName:'Katz',
  firstName:'Nevin',
  bookTitle:'Dr. Birdley Teaches Science: Parts of the Cell',
  bookDate:'May 1, 2007'
};


printBook(book);

/* I find myself using a utility function like this routinely now. Below is a working demo of the above example. */