imposerfromamongsus

Untitled

Nov 13th, 2021 (edited)
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function getRandomInt(min, max) {
  2.     min = Math.ceil(min);
  3.     max = Math.floor(max);
  4.     return Math.floor(Math.random() * (max - min) + min); //The maximum is exclusive and the minimum is inclusive
  5. };
  6.  
  7. function getRndNum(min, max) {
  8.     let x = Math.random() * (max - min) + min;
  9.     return x.toPrecision(getRandomInt(2,5));
  10. };
  11.  
  12. var letter_grades = document.getElementsByClassName("mark");
  13. var percentages = document.getElementsByClassName("score");
  14. var missing_assignments = document.getElementsByClassName("class-item-lessemphasis hide-for-print");
  15.  
  16. for (var i = 0; i < letter_grades.length; i++) { // there _should_ be as many marks as there are scores, so this works
  17.     missing_assignments.item(i).childNodes[1].innerText = "0 Missing Assignments";
  18.     var new_percentage = getRndNum(80, 100);
  19.     console.log(letter_grades.item(i).childNodes[0].data);
  20.     percentages.item(i).childNodes[0].data = new_percentage.toString() + "%";
  21.     if (new_percentage < 83) {
  22.         letter_grades.item(i).childNodes[0].data = "B-";
  23.     }
  24.     else if (new_percentage < 87){
  25.         letter_grades.item(i).childNodes[0].data = "B";
  26.     }
  27.     else if (new_percentage < 90){
  28.         letter_grades.item(i).childNodes[0].data = "B+";
  29.     }
  30.     else if (new_percentage < 93){
  31.         letter_grades.item(i).childNodes[0].data = "A-";
  32.     }
  33.     else if (new_percentage < 98){
  34.         letter_grades.item(i).childNodes[0].data = "A";
  35.     }
  36.     else if (new_percentage >= 98) {
  37.         letter_grades.item(i).childNodes[0].data = "A+";
  38.     }
  39. };
Add Comment
Please, Sign In to add comment