Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

1
Convert number grade to letter grade help
Post Body

Hey guys, I'm pretty new to JavaScript and I'm trying to build a program that converts a number grade to a letter grade. When I go and try to run the code and enter a number such as '75', I get the output 'F' and this goes for every number '85', '90' etc, I still get the output 'F'. Could someone please help me try to understand where I went wrong? Thanks.

<!DOCTYPE html>
<html lang = "en">
<head>
<meta charset = "utf-8" />

<title>Grade Converter</title>

</head>
<body>

<h3>Grade</h3>

<input type="text" id="numGrade" />
<button onclick="convert()">Convert</button>

<br></br>
Grade:<span id="letterGrade"></span>

<script src = "example1.js">
</script>
</body>
</html>

let num = document.getElementById('numGrade').value;

function convert(){

    let numeric = parseInt(num);
    let letterGrade = '';


    if(num >= 90 && num <= 100)
    {
        letterGrade = "A ";
    }
    else if(num >= 80 && num <= 89)
    {
        letterGrade = "A";
    }
    else if(num >= 75 && num <= 79)
    {
        letterGrade = "B ";
    }
    else if(num >= 70 && num <= 74)
    {
        letterGrade = "B";
    }
    else if(num >= 65 && num <= 69)
    {
        letterGrade = "C ";
    }
    else if(num >= 60 && num <= 64)
    {
        letterGrade = "C";
    }
    else if(num >= 55 && num <= 59)
    {
        letterGrade = "D ";
    }
    else if(num >= 50 && num <= 54)
    {
        letterGrade = "D";
    }
    else if(num >= 48 && num <= 49)
    {
        letterGrade = "E";
    }
    else if (num >= 0 && num <= 47)
    {
        letterGrade = "F";
    }
    else
    {
        letterGrade = "You entered the wrong grade.";
    }
    document.getElementById("letterGrade").innerHTML=letterGrade;
   
}

Author
Account Strength
60%
Account Age
3 years
Verified Email
Yes
Verified Flair
No
Total Karma
26
Link Karma
16
Comment Karma
10
Profile updated: 3 days ago
Posts updated: 3 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
6 months ago