Question: 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
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
