Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getRandomInt(min, max) {
- min = Math.ceil(min);
- max = Math.floor(max);
- return Math.floor(Math.random() * (max - min) + min); //The maximum is exclusive and the minimum is inclusive
- };
- function getRndNum(min, max) {
- let x = Math.random() * (max - min) + min;
- return x.toPrecision(getRandomInt(2,5));
- };
- var letter_grades = document.getElementsByClassName("mark");
- var percentages = document.getElementsByClassName("score");
- var missing_assignments = document.getElementsByClassName("class-item-lessemphasis hide-for-print");
- for (var i = 0; i < letter_grades.length; i++) { // there _should_ be as many marks as there are scores, so this works
- missing_assignments.item(i).childNodes[1].innerText = "0 Missing Assignments";
- var new_percentage = getRndNum(80, 100);
- console.log(letter_grades.item(i).childNodes[0].data);
- percentages.item(i).childNodes[0].data = new_percentage.toString() + "%";
- if (new_percentage < 83) {
- letter_grades.item(i).childNodes[0].data = "B-";
- }
- else if (new_percentage < 87){
- letter_grades.item(i).childNodes[0].data = "B";
- }
- else if (new_percentage < 90){
- letter_grades.item(i).childNodes[0].data = "B+";
- }
- else if (new_percentage < 93){
- letter_grades.item(i).childNodes[0].data = "A-";
- }
- else if (new_percentage < 98){
- letter_grades.item(i).childNodes[0].data = "A";
- }
- else if (new_percentage >= 98) {
- letter_grades.item(i).childNodes[0].data = "A+";
- }
- };
Add Comment
Please, Sign In to add comment