-5
<script type="text/javascript">
 var score = prompt("Enter your score. Grade must be between 100-0.");

 if ( score>==90 ) 
    {
        document.write ( "Your grade is an A." )
    }
else if ( score <89>==80 )
    {
        document.write ( "Your grade is a B." )
    }
else if ( score <79>==70 )
    {
        document.write ( "Your grade is a C.")
    }
else if ( score <69>==60 ) 
    {
        document.write ( "Your grade is a D.")
    }
else if ( score <59>==0 )
    {
        document.write ( "Your grade is a F")
   }

}//end if
</script>
jmoerdyk
  • 5,544
  • 7
  • 38
  • 49
  • What error? What are you haveing trouble with? – cliff2310 Apr 19 '16 at 22:30
  • Your `if` statements are not valid. To check whether a value is between 2 other values, you should use [this method](http://stackoverflow.com/a/14718577/1913729). However, in your case, I believe [this will be enough](https://jsfiddle.net/gyq2296p/). – blex Apr 19 '16 at 22:30
  • You tagged this as Java, and didn't post what exactly you have a problem with – touch my body Apr 19 '16 at 22:31
  • Welcome to Stack Overflow! Here are some guidelines to asking good questions for future reference. http://stackoverflow.com/help/how-to-ask For starters, you should do some research. A quick google search of javascript if statements should reveal you're using invalid operators and that you can use `&&` for checking multiple conditions. Assuming you don't find this information however, you should try to ask your question in the form of a question. "I'm trying to assign a grade based on score, but I can't get it to work. I try to run, and here's what happens. Here's my code, how do i fix this?" – Monkeygrinder Apr 19 '16 at 23:29

3 Answers3

0

This is a JavaScript question but you need to learn about the "and" operator. You really want each "else" to be something like:

else if ( score <= 89 && score >= 80 )

for all of the "else if" statements. That could really be simplified if you just have the second part, i.e.

else if ( score >= 80 )

since you already checked for 90 and above previously.

EDIT - and I was beaten to my edit - you can't use the <== or >== operators.

stdunbar
  • 16,263
  • 11
  • 31
  • 53
0

I'm not exactly sure what you're looking for, since you didn't ask a question, but I'm guessing it's this:

<script type="text/javascript">
 var score = prompt("Enter your score. Grade must be between 100-0.");

    if ( score >== 90 ) 
    {
        document.write ( "Your grade is an A." )
    }
    else if ( score >== 80 )
    {
        document.write ( "Your grade is a B." )
    }
    else if ( score >==70 )
    {
        document.write ( "Your grade is a C.")
    }
    else if ( score >==60 ) 
    {
        document.write ( "Your grade is a D.")
    }
    else if ( score >== 0 )
    {
        document.write ( "Your grade is a F")
    }

}//end if
</script>

You might want to read up on if statements in javascript. Usually you put one condition that evaluates to true or false, such as thing a >== thing b.

touch my body
  • 1,634
  • 22
  • 36
-1

Should be

if ( score>==90 ) 
 {
    document.write ( "Your grade is an A." )
 }
else if ( score >==80 )
{
    document.write ( "Your grade is a B." )
} 
else if ( score >==70 )
{
    document.write ( "Your grade is a C.")
}
else if ( score >==60 ) 
 {
    document.write ( "Your grade is a D.")
 }
else if ( score >==0 )
{
    document.write ( "Your grade is a F")
 }
Ayo K
  • 1,719
  • 2
  • 22
  • 34