I am struggling to generate buttons for each JSON array within the given JSON object. There are 2 arrays, and I aim to add child buttons to these initial buttons for every object in the arrays (a total of 6 objects). Even though I have written some code that I believe should work, it only results in an error. Below is the JavaScript code I have used. I've been working on this for a few days now and time is running out, so any guidance or advice would be greatly appreciated.
<body>
<div id="title"> <!-output how many modules there are with .length-->
</div>
<div id="nav">
</div>
<script>
$( document ).ready(function() {
$.getJSON( "courses.json", function( json ) {
for (var i in Object.keys(json)) {
var btn = document.createElement("BUTTON");
document.getElementById("nav").appendChild(btn);
btn.id = "myBtn";
$.each(i, (function(j) {
var btns = document.createElement("BUTTON");
document.getElementById("myBtn").appendChild(btns);
}))
}
})
})
</script>
</body>
//JSON:
{
"semester1": [
{"code":"CS6100",
"title":"Multimedia Authoring",
"Credit Weighting":5,
"Content":"Programming in Processing",
"Assessment":{"CA":40,"exam":60},
"link":"https://www.ucc.ie/admin/registrar/modules/?mod=CS6100"},
{"code":"CS6101",
"title":"Web Development for Digital Media",
"Credit Weighting":5,
"Content":"Web Development with programming in Client and Server Side Languages",
"Assessment":{"CA":40,"exam":60},
"link":"https://www.ucc.ie/admin/registrar/modules/?mod=CS6101"},
{"code":"CS6102",
"title":"Graphics for Interactive Media",
"Credit Weighting":5,
"Content":"Programming in Python. The principles, practices, technologies and critical frameworks associated with the practice of graphic design for digital media. Develop understanding of the creative and technical aspects of image capture, editing and manipulation. Production of graphics for digital media using industry-standard tools.",
"Assessment":{"CA":40,"exam":60},
"link":"https://www.ucc.ie/admin/registrar/modules/?mod=CS6102"},
{"code":"CS6103",
"title":"Audio and Sound Engineering",
"Credit Weighting":5,
"Content":"Introduction to the technologies and techniques used in digital audio. Physics of sound and the psycho-physiological basis of hearing. Sound engineering, production and post-production.",
"Assessment":{"CA":40,"exam":60},
"link":"https://www.ucc.ie/admin/registrar/modules/?mod=CS6103"},
{"code":"CS6104",
"title":"Digital Video Capture and Packaging",
"Credit Weighting":5,
"Content":"Develop understanding of the planning, production and post-production of digital video. Application and evaluation of industry-standard tools in capturing, processing and packaging digital video.",
"Assessment":{"CA":40,"exam":60},
"link":"https://www.ucc.ie/admin/registrar/modules/?mod=CS6104"},
{"code":"CS6111",
"title":"3D Graphics and Modelling",
"Credit Weighting":5,
"Content":"Tools, techniques and processes involved in 3D graphics design, modelling and rendering. Create appropriate models of 3D objects and scenes. Solving problems in curve, surface and solid modeling.",
"Assessment":{"CA":40,"exam":60},
"link":"https://www.ucc.ie/admin/registrar/modules/?mod=CS6111"}
],