I am struggling to target and display an HTML id tag only when a corresponding JS object in an array has a "live" value of true. How can I achieve this?
My goal is to have a JavaScript loop that displays a link in the schedule module if the link id matches the "scheduleId" of an object, and the "live" value of that object is true. Can you help me with targeting and displaying this link?
Check out my HTML below:
<div class="test-schedule">
<h2>Schedule</h2>
<div><span>School of Ed</span><a class="link-class" id="ed">School of Ed link</a></div>
<div><span>School of Humanities</span><a class="link-class" id="hss">School of Humanities link</a></div>
<div><span>School of Science</span><a class="link-class" id="sci">School of Science link</a></div>
<div><span>School of Nursing</span><a class="link-class" id="nursing">School of Nursing link</a></div>
</div>
<style>
.link-class{display:none}
</style>
Here is the JavaScript part:
const eventList = [
{
scheduleId: 'ed',
live: 'true',
},
{
scheduleId: 'hss',
live: 'false',
},
{
scheduleId: 'sci',
live: 'false',
},
{
scheduleId: 'nursing',
live: 'false',
},
];
Link to Codepen: https://codepen.io/lvl12sealclubber/pen/PoWbJZQ?editors=1011