Answered step by step
Verified Expert Solution
Question
1 Approved Answer
How to convert this code so that a function will read an external JSON data file then convert data into a JavaScript object using JSON.parse
How to convert this code so that a function will read an external JSON data file then convert data into a JavaScript object using JSON.parse
The value of the parameter that you will pass to the function is: "databooksjson".
The second parameter is the name of the function that must be run after the file has been read from the server. This is your callback function.
HERE IS Mlet tableBody document.querySelectortbody;
function booksObject
let books
:
title : "DATA SCIENCE & BIG DATA ANALYSIS",
price :
quantity :
:
title : "PRINCIPLES OF DATABASE MANAGEMENT",
price :
quantity :
:
title : "CCNA ROUTING & SWITCHING PORTABLE COMMAND GUIDE",
price :
quantity :
:
title : "CCNA ROUTING AND SWITCHING : EXAM",
price :
quantity :
:
title : "HANDSON MICROSOFT WINDOWS SERVER
price :
quantity :
:
title : "INTRODUCTION TO WEB DEVE",
price :
quantity :
:
title : "MURACH'S PHP AND MYSQL
price :
quantity :
:
title : "REVEL FOR LIANG JAVA ACCESS CARD",
price :
quantity :
if documentreadyState 'loading'
document.addEventListenerDOMContentLoaded booksObject;
else
booksObject;
function createTableRowsbooks
const fragment document.createDocumentFragment;
for const books of data
const row document.createElementtr;
const isbnCell document.createElementtd;
const titleCell document.createElementtd;
const priceCell document.createElementtd;
const quantityCell document.createElementtd;
const totalCell document.createElementtd;
isbnCell.textContent book.isbn;
titleCell.textContent book.title;
priceCell.textContent book.price;
quantityCell.textContent book.quantity;
const totalPrice book.price book.quantity;
totalCell.textContent totalPrice;
row.appendChildisbnCell;
row.appendChildtitleCell;
row.appendChildpriceCell;
row.appendChildquantityCell;
row.appendChildtotalCell;
fragment.appendChildrow;
tableBody.appendChildfragment;
createTableRowsbooks;
;Y CODE:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started