2

I am making a to do list and i am trying to make a JSON file to link the objects for each Item on the to-do.

Im not really sure what I am meant to do and i am not sure what i am meant to look for with help.

// This is an example object
{
 "id":"01",
 "desc":"Do the To-Do List"
 },

I hope to be-able to view the objects I draw from the JSON file and show it as a table.

1 Answer 1

2

If you want to show it as a table (and each object has the id and desc properties) loop over each object (I assume they're in an array of objects) and make a new row:

const data = [{"id":"01","desc":"Do the To-Do List"},{"id":"02","desc":"Number Two!"},{"id":"03","desc":"A third option"}];
const table = document.getElementById("table");
data.forEach(({ id, desc }) => table.innerHTML += `<tr><td>${id}</td><td>${desc}</td></tr>`);
<table id="table" border="1">
  <tr>
    <th>Id</th>
    <th>Desc</th>
  </tr>
</table>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.