我想將所有循環數據存儲到Course_Code
和Grade
陣列中。如何將循環數據存儲到數組中?
除了只存儲最後輸入的值以外的所有工作。我必須做些什麼來保存數組中的所有數據?
const MIN = 999;
const MAX = 10000;
const minLet = 64;
const maxLet = 91;
const GRADE_VALUE = 'parseInt(7)%parseInt(6)%parseInt(5)%parseInt(4)%parseInt(3)%parseFloat(1.5)';
var i;
var j;
var Grade = new Array();
var Course_Code = new Array();
while (willingnes != false) {
var willingnes = confirm('Do you want to enter new Course Code? Click OK to continue or Cancel to stop?');
if (willingnes == true) {
Course_Code = prompt('Enter your Course Code', 'AAA1000');
var Digits = parseInt(Course_Code.slice(-4)); // extract the last four digits from course code
while (Course_Code.charCodeAt(0) < minLet || Course_Code.charCodeAt(0) > maxLet || Course_Code.charCodeAt(1) < minLet || Course_Code.charCodeAt(1) > maxLet || Course_Code.charCodeAt(2) < minLet || Course_Code.charCodeAt(2) > maxLet || isNaN(Digits) || Digits < MIN || Digits > MAX) {
alert('Your input was invalid');
Course_Code = prompt('Enter your Course Code', 'AAA1000');
}
Grade = prompt('Input a valid Course grade:');
while (GRADE_VALUE.indexOf(Grade) < 0) {
alert('Invalid Course value.');
Grade = prompt('Re-enter valid course grade:');
}
}
}
alert(Course_Code);
alert(Grade);
謝謝,推動工作 – Rambs