2016-04-19 4 views
-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> 
+0

どのようなエラー?あなたは何の問題を抱えていますか? – cliff2310

+0

'if'ステートメントが無効です。値が他の2つの値の間にあるかどうかを確認するには、[this method](http://stackoverflow.com/a/14718577/1913729)を使用する必要があります。しかし、あなたの場合、私は[これで十分です](https://jsfiddle.net/gyq2296p/)と信じています。 – blex

+0

は、Javaとしてこれをタグ付け、そしてあなたは、スタックオーバーフローに –

答えて

-1

を私の誤りを見つける手助けが必要

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") 
} 
0

であるべきこれは、Javaスクリプト質問ですが、あなたは「と」オペレータについて学ぶ必要があります。あなたは本当にそれぞれの "else"を次のようなものにしたいと考えています:

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

すべての "else if"ステートメント。これはすでに90度以上チェックしているので、2番目の部分(

else if (score >= 80) 

)を持っていると、実際には単純化できます。

EDIT - と私は私の編集に殴られました - あなたは< ==または> ==演算子を使用することはできません。

+1

'<==' and '> =='は無効で、エラーが発生します。 '> ='または '<='である必要があります – blex

+0

これらのごみの質問にはお答えください。あなたは悪い先例を続けています。 – Savior

0

あなたが質問をしていなかったが、私はそれがこのだ推測しているので、私は、あなたが探しているものを正確にはわからない:

<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> 

あなたはif statements in javascript上に読みたいかもしれません。通常は、このような> == thing bthing aとして、真または偽と評価条件を1つ置きます。

関連する問題