私のコードは 2+2=4 のような数値を追加しませんが、 2+2=22 のように追加します。変数が数値であることを認識するように、これをどのように変更できるか疑問に思っていました。
var gra=0;
var graTwo=0;
var graThree=0;
var stu = prompt("Who are you grading?");
var gra = prompt("Oh, what is " +stu+ "'s grade?")
if(gra>80) {
alert("Congrats, " +stu+ ". Have a gold star!")
}
else {
alert("Wow, thats awful " +stu+ ", try again")
};
var stuTwo = prompt("Who are you grading?")
var graTwo = prompt(" Oh, what is " +stuTwo+ " 's grade?")
if(graTwo>80) {
alert("Congrats, " +stuTwo+ ". Have a gold star!")
}
else {
alert("Wow, thats awful " +stuTwo+ ", try again")
};
var stuThree = prompt("Who are you grading?");
var graThree = prompt("Oh, what is" +graThree+ "'s grade?")
if(graThree>80) {
alert("Congrats, " +stuThree+ ". Have a gold star!");
}
else {
alert("Wow, thats awful " +stuThree+ ", try again")
};
var add = (gra+graTwo+graThree);
alert(add)
alert("The average grade of your class is ")