var counter = 1;

function newliner(){
    counter += 1;
    var child = document.getElementById("sample");
    child = child.cloneNode(true);
    child.id = "";
    child.children[0].textContent = counter;
    child.children[1].children[0].value = "";
    child.children[2].children[0].value = "";
    child.children[3].children[0].value = 0;
    document.getElementById("MainTable").appendChild(child);
    updateaverage();
}

function updateaverage(){
    var marks = Array.from(document.getElementsByClassName("marks"));
    var avg = 0;
    for(var i = 0; i < marks.length; i++){
        if(Number(marks[i].value) == 0){
            avg += 1
        }else{
            avg += Number(marks[i].value);
        }
    }
    avg = Math.floor((avg * 100) / marks.length);
    avg = avg / 100;
    document.getElementById("average").textContent = `Az átlag: ${avg}`;
}