var nameList = document.querySelectorAll("table tr > td:nth-child(2)");
var salList = document.querySelectorAll("table tr > td:nth-child(6)");
var commList = document.querySelectorAll("table tr > td:nth-child(7)");
var name, sal, comm;
var annualSal;
var totalSal = 0;
var deptTH = document.querySelector("table tr > th:nth-last-child(2)");
var annSalTH = document.createElement("th");
annSalTH.textContent = "연봉";
deptTH.parentNode.insertBefore(annSalTH, deptTH)
console.log(annSalTH);
for(var i=0; i<nameList.length; i++) {
name = nameList[i].textContent;
sal = parseFloat(salList[i].textContent);
comm = parseFloat(commList[i].textContent);
annualSal = sal*12 + comm;
console.log("%s님의 연봉은 %f입니다...", name, annualSal);
totalSal += annualSal;
var annSalNode = document.createElement("td")
annSalNode.textContent = annualSal;
commList[i].parentNode.insertBefore(annSalNode, commList[i].nextSibling);
}
document.querySelector("#total_sal").textContent = totalSal;
|