2017-04-27 3 views
-2

Ich möchte alle geloopten Daten in den Course_Code und Grade Arrays speichern.Wie kann ich geloopte Daten in einem Array speichern?

Alles funktioniert, nur dass nur der zuletzt eingegebene Wert gespeichert wird. Was muss ich tun, um alle Daten im Array zu speichern?

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

Antwort

Verwandte Themen