我的代码确实添加了 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 ")