如果没有学生姓名,或者输入的标记不在0到100之间,我希望程序退出:
var student = prompt("Please enter a student name [Press Cancel to exit]", "Cancel");
while(student !== null) {
studentName.push(student);
student = prompt("Please enter a student name [Press Cancel to exit]","Cancel");
}
function checkStudent() {
for(var i = 0;i<studentName;i++) {
if(studentName === null) {
break;
}
}
return document.write("We can't proceed if there is no student name");
}
checkStudent();
var mark = prompt("Please enter a mark[Press Cancel to exit]","Cancel");
while(mark!== null) {
marks.push(mark);
mark = prompt("Please enter a mark[Press Cancel to exit]", "Cancel");
}
function checkMark() {
if(mark< 0 || 100<mark) {
return
}
}
checkMark()
document.write("Please enter a mark between 0 and 100")