Testing Your Skills (Hack #1)

How Conditionals Work: if statement: The condition inside the if block checks if the score is greater than or equal to 90. If true, it runs the block of code that prints “A”.

else if statement: This checks another condition if the first if statement is false. Each else if provides an additional condition to check, such as whether the score is between 80 and 89.

else statement: The else block runs if none of the previous conditions are true. This is the fallback case, which in this example applies to any score below 70.

function getGrade() {
    let score = prompt("Enter the score (0-100):");
    score = Number(score);  // Convert input to a number
  
    if (score >= 90) {
      console.log("A");
    } else if (score >= 80) {
      console.log("B");
    } else if (score >= 70) {
      console.log("C");
    } else {
      console.log("F");
    }
  }
  
  // Call the function to get a grade
  getGrade();