how to ask user for their score in 4 tests that has a grade limit of 0-100 then if the student or the user has no test for each of exam the program display incomplete in javascript

index.tsx
//Ask the user for scores in each test and store them in variables
let test1 = parseInt(prompt("Enter score for test 1 (0-100):"));
let test2 = parseInt(prompt("Enter score for test 2 (0-100):"));
let test3 = parseInt(prompt("Enter score for test 3 (0-100):"));
let test4 = parseInt(prompt("Enter score for test 4 (0-100):"));

//Validate if the user has entered a score between 0-100 for each test
if (test1 >= 0 && test1 <= 100 && test2 >= 0 && test2 <= 100 && test3 >= 0 && test3 <= 100 && test4 >= 0 && test4 <= 100) {
  //Calculate the average of all test scores
  let average = (test1 + test2 + test3 + test4) / 4;
  
  //Display the average of all test scores
  console.log(`Your test average is ${average.toFixed(2)}`);
} else {
  //Display message if the user has not entered a valid score for any of the tests
  console.log("Incomplete");
}
851 chars
18 lines

gistlibby LogSnag