JSFiddle - React, Tailwind, and code Playground

by Michel Plungjan

JavaScript

//Javascript
var html = "";
//Table headers
html += "<table><th style='width:25px'>No.</th>";
html += "<th style='width:100px'>Name</th>";
html += "<th style='width:100px'>Attendance</th>";
html += "<th style='width:100px'>Homework</th>";
html += "<th style='width:100px'>Midterm Test</th>";
html += "<th style='width:100px'>Final Exam</th>";
html += "<th style='width:100px'>Final Grade</th>";
html += "<th style='width:100px'>Letter Grade</th>";

//Setting the component weightage
do {
  var weightAtt = parseFloat(prompt("Enter the weightage of attendance"));

  while (weightAtt <= 0 || weightAtt >= 1 || isNaN(weightAtt)) {
    alert("The weightage of attendance must a positive number less than 1");
    var weightAtt = parseFloat(prompt("Enter the weightage of attendance"));
  }

  var weightHw = parseFloat(prompt("Enter the weightage of homework"));

/* looping forever on playwright
  while (weightHw <= 0 || weightHw >= 1 || isNaN(weightHw)) {
    alert("The weightage of homework must a positive number less than 1");
    var weighthw = parseFloat(prompt("Enter the weightage of homework"));
  }

  var weightMdt = parseFloat(prompt("Enter the weightage of midterm test"));

  while (weightMdt <= 0 || weightMdt >= 1 || isNaN(weightMdt)) {
    alert("The weightage of midterm test must a positive number less than 1");
    var weightMdt = parseFloat(prompt("Enter the weightage of midterm test"));
  }

  var weightFx = parseFloat(prompt("Enter the weightage of final exam"));

  while (weightFx <= 0 || weightFx >= 1 || isNaN(weightFx)) {
    alert("The weightage of final exam must a positive number less than 1");
    var weightFx = parseFloat(prompt("Enter the weightage of final exam"));
  }
  if ([weightAtt + weightHw + weightMdt + weightFx] != 1) {
    alert("The total weightage of all components must be equals to 1!");
  }
}
while ([weightAtt + weightHw + weightMdt + weightFx] !=...