I want to loop through Elements that was added asynchronously using fetch. Can somebody help? This is what I tried:
How I appended the Elements
    const body = document.querySelector("body");
    body.onload = function(){
        //loads the list of subjects
        getSubjects().then((data) => {
            let subjectSrting = ""; //initialize variable that holds the html of all the subjects semester wise
            // loops around each semester                
            data.forEach(function(semester){                    
                subjectSrting += "<div class='semester'> <div class='title yearTitle'>"+ semester.year +"</div> <div class='title semesterTitle'>"+ semester.semester +"</div>";
                // loops around each subject for each semester
                semester.subjects.forEach(function (subject){
                    let dis = ""
                    if(subject.type != "C"){
                        dis = "disabledSub";
                    }
                    subjectSrting += "<div class='subject "+dis+"'> <div class='sub'><span class='code'>" + subject.code + "</span><span class='name'>" + subject.name + "</span></div> <div class='subCredits'>" + subject.cred + "</div> <div class='attempt'> <input type='checkbox' id='" + subject.code + "' checked><label for='" + subject.code + "'>1st</label> </div> <button type='button' data_gpv='-1'  class='subResult'>SELECT</button> </div>";
                });                    
                subjectSrting += "</div>";
            });                
            let form = document.querySelector(".home form");
            form.innerHTML = subjectSrting;               
        })
    }
Here's where I find trouble to loop around the elements to get data-gpv values and to see if the checkboxes that were appended are checked or not:
    function calculateGpa(){
        let subjects = document.getElementsByClassName("home")[0].getElementsByClassName('subject');
        console.log(subjects.length); //logs 0, eventhough there are items in the HTMLCollection
        console.log(subjects); //logs a an HTMLCollection[] with the elements in it
        for(var i=0; i<subjects.length; i++){
            // get the gpv values and see if the chechbox is checked
            // cannot run this because subjects.length return 0
        }  
    }
    calculateGpa();