Skip to content

Instantly share code, notes, and snippets.

@DongTran308
Forked from shivaluma/avg.js
Created May 26, 2021 16:30
Show Gist options
  • Select an option

  • Save DongTran308/07d39af80d7e491f2a1daf347722fc34 to your computer and use it in GitHub Desktop.

Select an option

Save DongTran308/07d39af80d7e491f2a1daf347722fc34 to your computer and use it in GitHub Desktop.
Tinh diem trung binh hcmus
// tinh diem trung binh hcmus, vao trang diem va paste vao console.
// khong tinh anh van, quoc phong, the duc va nhung mon rot
var tinchi = document.querySelectorAll("td:nth-child(3)");
var monhoc = document.querySelectorAll("td:nth-child(2)");
var diem = document.querySelectorAll("td:nth-child(6)");
var diemtren = 0,
diemduoi = 0;
for (var i = 1; i < tinchi.length; i++) {
if (
monhoc[i].innerText.includes("Thể dục") ||
monhoc[i].innerText.includes("Anh văn") ||
monhoc[i].innerText.includes("Giáo dục") || Number(diem[i].innerText) < 5
) {
continue;
}
diemtren += Number(tinchi[i].innerText) * Number(diem[i].innerText);
diemduoi += Number(tinchi[i].innerText);
}
console.log("Tong tin chi : " + diemduoi);
console.log("Diem trung binh : " + diemtren / diemduoi);
@DongTran308
Copy link
Author

var tinchi = document.querySelectorAll("td:nth-child(3)");
var monhoc = document.querySelectorAll("td:nth-child(2)");
var diem = document.querySelectorAll("td:nth-child(6)");
var diemtren = 0,
diemduoi = 0;
var diemSPtren = 0,
diemSPduoi = 0;
for (var i = 1; i < tinchi.length; i++) {
if (
monhoc[i].innerText.includes("Thể dục") ||
monhoc[i].innerText.includes("Anh văn") ||
monhoc[i].innerText.includes("Giáo dục") ||
Number(diem[i].innerText) < 5
) {
continue;
} else if (monhoc[i].innerText.includes("CSC")) {
//sửa CSC nếu muốn tính điểm nhóm môn khác, vd PHY, MTH,...
diemSPtren += Number(tinchi[i].innerText) * Number(diem[i].innerText);
diemSPduoi += Number(tinchi[i].innerText);
}
diemtren += Number(tinchi[i].innerText) * Number(diem[i].innerText);
diemduoi += Number(tinchi[i].innerText);
}
console.log("Tong tin chi : " + diemduoi);
console.log("Diem trung binh : " + diemtren / diemduoi);
console.log("Tong tin chi mon SP: " + diemSPduoi);
console.log("Diem trung binh SP: " + diemSPtren / diemSPduoi);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment