嵌套 For 循环在 27 项中的 22 项后退出,运行 在节点服务器端
Nested For loop exited after 22 items in 27 items, running on Node server side
[已修改]
这里可以提供一点帮助。
我 运行 遇到了 for 循环的问题。我有一个 for 循环嵌套在另一个中。外层循环只有 level 元素,而嵌套层只包含 27 个项目。
问题是安装程序在退出前只能 运行 通过嵌套数组的 22 项。
在服务器端 运行 设置,在 node.js 中完成。客户端是 React,它通过 websocket 与服务器通信。从控制台报告中,node.js 运行s 上述代码 3x;在所有这些时间里,只有 22 项超出了预期的 27 项。
加入 Repl 以获得完整的 Node.js 目录:
https://replit.com/join/uabhesdiif-emexrevolarter
下面的代码。我感谢任何帮助。谢谢。
VerifyResult.js
let data = {};
let error = [];
let feedback = [];
if(typeof dataJson == 'string') {
data = JSON.parse(dataJson)
} else {
data = dataJson;
}
try {
// get variables
const getAvatarState = data.settings.isAvatar;
const getIdState = data.settings.isAdminId;
const getStudents = data.students[0]['Students Data'];
const getClassInfo = data.students[0]['Class Info'][0];
const getAvatars = data.images;
const getLogo = data.logo;
const getFilenames = data.filenames;
const getFirstTermState = data.settings.isFirstTerm;
const getSecondTermState = data.settings.isSecondTerm;
const getThirdTermState = data.settings.isThirdTerm;
const getSubjectList = data.subjects;
let getFirstTerm = [];
let getSecondTerm =[];
let getThirdTerm = [];
// verify #1: if avatars are permitted & same number of images included
if(getAvatarState == '1') {
if(getStudents.length > getAvatars.length) {
feedback.push(`${getAvatars.length} Images supplied for Avatar is lesser than the number of ${getStudents.length} students`);
feedback.push('Some Results may not include Avatar')
}
if(getStudents.length < getAvatars.length) {
feedback.push(`${getAvatars.length} Images supplied for Avatar is more than the number of ${getStudents.length} students`);
feedback.push('This may not pose any problem except possible mismatch')
}
} else {
feedback.push('Avatar will not be included in any result')
}
// verify #2: if logo is included
if(getLogo == null) {
feedback.push('No image was added as logo, and hence, will not be included')
}
// verify #3: if empty value for Admin Numbers, Names, in Students file
let idList = [];
let countItem = 0;
let innerCount = 0;
for(let k = 0; k < getStudents.length; k++) {
let d = getStudents[k];
countItem = k + 1;
let fName, lName;
if(getIdState == '1') {
if(d.Admin_Number != undefined && d.Admin_Number != '') {
idList.push(d.Admin_Number);
} else {
error.push(`Admin Number for Student at row "${countItem}" is empty, in Students workbook`)
}
}
if(d.Firstname != undefined && d.Firstname != '') {
fName = d.Firstname
} else {
error.push(`Firstname for Student at row "${countItem}" is empty, in Students workbook`)
}
if(d.Surname != undefined && d.Surname != '') {
lName = d.Surname
} else {
error.push(`Surname for Student at row "${countItem}" is empty, in Students workbook`)
}
if(fName != undefined && lName != undefined) {
(getIdState == '0') && idList.push(`${lName}/${fName}`);
}
};
// verify #4: if IDs for Students file is unique
if(!IsArrayUnique(idList)) {
(getIdState == '1') && error.push(`One or Student Admin Numbers are not unique, in Students file`);
(getIdState == '0') && error.push(`One or more Student names are not unique, in Students file`);
}
// verify #5: if empty value for Class Info, in Students file
if(getClassInfo.Class_Name == undefined) {
error.push('Class Name of Class Info worksheet is empty, in Students file')
}
if(getClassInfo.School == undefined) {
error.push('School Name of Class Info worksheet is empty, in Students file')
}
if(getClassInfo.Session == undefined) {
error.push('Session of Class Info worksheet is empty, in Students file')
}
if(getClassInfo.Times_School_Opened == undefined) {
error.push('No of Times School Opened of Class Info worksheet is empty, in Students file')
}
countItem = 0;
for(let i = 0; i < getSubjectList.length; i++) {
let sub = getSubjectList[i];
let gFile = getFilenames[i];
countItem = i + 1;
let innError = false;
let list = [];
let subj, fName, lName, sName, termName;
if(getFirstTermState == '1') {
// verify #6: if empty value in Subject files for First Term
innError = false;
termName = 'First Term';
subj = sub['First Term'];
if(sub['Class Info'][0].Class_Name == undefined) {
innError = true;
error.push(`Class Name in ${gFile} is empty`)
}
if(sub['Class Info'][0].Subject == undefined) {
innError = true;
error.push(`Subject Name in ${gFile} is empty`)
}
if(subj < 1) {
innError = true;
error.push(`Subject scores for ${termName} cannot be found in ${gFile}`)
}
if(!innError) {
console.log('==== STUDENTS TOTAL: ', subj.length);
innerCount = 0;
for(let j = 0; j < subj.length; j++) {
let item = subj[j];
innerCount = j + 1;
if(item.Surname == undefined) {
innError = true;
error.push(`Surname for a Student at row ${innerCount} is empty, for ${termName} in ${gFile}`)
}
if(item.Firstname == undefined) {
innError = true;
error.push(`Firstname for a Student at row ${innerCount} is empty, for ${termName} in ${gFile}`)
}
if(item.Admin_Number == undefined && getIdState == '1') {
innError = true;
error.push(`Admin Number for a Student at row ${innerCount} is empty, for ${termName} in ${gFile}`)
}
if(!innError) {
fName = item.Firstname;
lName = item.Surname;
if(item.CA == undefined && !innError) {
innError = true;
error.push(`CA for "${lName} ${fName}" at row ${innerCount} is empty, for ${termName} in ${gFile}`)
}
if(item.Exam == undefined && !innError) {
innError = true;
error.push(`Exam for "${lName} ${fName}" at row ${innerCount} is empty, for ${termName} in ${gFile}`)
}
}
// verify #7: if both CA & Exam are numbers for First Term
if(!innError) {
console.log('====== TOTAL READ: ', innerCount + ' | ' + countItem);
console.log('====== IS CA A NUMBER?: ', item.CA + ' | ' + IsNumber(item.CA));
console.log('====== IS Exam A NUMBER?: ', item.Exam + ' | ' + IsNumber(item.Exam));
if(!IsNumber(item.CA)) {
innError = true;
error.push(`CA for "${lName} ${fName}" at row ${innerCount} is not a number (${item.CA}), for ${termName} in ${gFile}`)
}
if(!IsNumber(item.Exam)) {
innError = true;
error.push(`Exam for "${lName} ${fName}" at row ${innerCount} is not a number (${item.Exam}), for ${termName} in ${gFile}`)
}
}
// verify #8: if Total is > 45 & < 50
if(!innError) {
const itemTotal = Number(item.CA) + Number(item.Exam);
if(itemTotal > 45 && itemTotal < 50) {
innError = true;
error.push(`The CA (CA: ${item.CA}; Exam: ${item.Exam}; Total: ${itemTotal}) for "${lName} ${fName}" at row ${innerCount}, should be upgraded to 50, for ${termName} in ${gFile}`)
}
}
if(!innError) {
if(getIdState == '1'){
sName = item.Admin_Number;
list.push(sName);
} else {
sName = lName + '/' + fName;
list.push(`${sName}`);
}
// verify #9: match IDs as Admin Number or Names for First Term
if(idList.indexOf(sName) === -1) {
innError = true;
(getIdState == '1') && error.push(`Student Admin Number "${sName}" is mismatched, for ${termName} in ${gFile}`);
(getIdState == '0') && error.push(`Student name "${lName} ${fName}" is mismatched, for ${termName} in ${gFile}`);
}
}
}
// verify #10: if unique IDs for First Term
if(!innError) {
if(idList.length == list.length) {
if(!IsArrayUnique(list)){
innError = true;
(getIdState == '1') && error.push(`One or more Student Admin Numbers are not unique, for ${termName} in ${gFile}`)
(getIdState == '0') && error.push(`One or more Student names are not unique, for ${termName} in ${gFile}`);
}
} else {
innError = true;
error.push(`Found ${list.length} Students against expected ${idList.length} number of Students, for ${termName} in ${gFile}`)
}
}
}
}
}
// verify #3: match admin Id is set as active, else match students names
} catch (err) {
error.push(err)
}
const res = {
data: data,
error: error,
feedback: feedback
}
data.json
{"settings":{"isAdminId":"1","isFirstTerm":"1","isSecondTerm":"0","isThirdTerm":"0","isAvatar":"1","isVerify":"1"},"subjects":[{"First Term":[{"Surname":"ADEOLA","Firstname":"TOLUWALASE","CA":38,"Exam":56,"Admin_Number":"AND/J/0271"},{"Surname":"ADEMOLA","Firstname":"SAMUEL","CA":35,"Exam":55,"Admin_Number":"ADM/J/0273"},{"Surname":"AGBONIRO","Firstname":"JESSE","CA":40,"Exam":54,"Admin_Number":"ADM/J/0284"},{"Surname":"AJAYI","Firstname":"ABIGAIL","CA":23,"Exam":33,"Admin_Number":"ADM/J/0269"},{"Surname":"AKANDE","Firstname":"MICHAEL","CA":29,"Exam":41,"Admin_Number":"ADM/J/0267"},{"Surname":"AKINTOKUN","Firstname":"MOFE","CA":27,"Exam":47,"Admin_Number":"ADM/J/0272"},{"Surname":"ARTHUR","Firstname":"DESTINY","CA":33,"Exam":55,"Admin_Number":"ADM/J/0266"},{"Surname":"AYANWENU","Firstname":"AKOREDE","CA":22,"Exam":35,"Admin_Number":"ADM/J/0270"},{"Surname":"BETHEL","Firstname":"MOYINULUWA","CA":40,"Exam":58,"Admin_Number":"ADM/J/0274"},{"Surname":"CHIJIOKE","Firstname":"JOY","CA":26,"Exam":44,"Admin_Number":"ADM/J/0276"},{"Surname":"CHINWUBA","Firstname":"CHARLES","CA":33,"Exam":40,"Admin_Number":"ADM/J/0275"},{"Surname":"DAVID","Firstname":"BEST","CA":40,"Exam":59,"Admin_Number":"ADM/J/0277"},{"Surname":"DUYILE","Firstname":"IFEOLUWA","CA":29,"Exam":41,"Admin_Number":"ADM/J/0256"},{"Surname":"EZEADILI","Firstname":"CHIBUNDU","CA":35,"Exam":49,"Admin_Number":"ADM/J/0278"},{"Surname":"FAGITE","Firstname":"TOBILOBA","CA":40,"Exam":57,"Admin_Number":"ADM/J/0279"},{"Surname":"IDOGEN","Firstname":"EHIZOFUA","CA":31,"Exam":51,"Admin_Number":"ADM/J/0282"},{"Surname":"IFADA","Firstname":"HOSSONA","CA":33,"Exam":50,"Admin_Number":"ADM/J/0255"},{"Surname":"IHEDIOHA","Firstname":"DELIGHT","CA":34,"Exam":53,"Admin_Number":"ADM/J/0280"},{"Surname":"JOSIAH","Firstname":"MATTHEW","CA":29,"Exam":49,"Admin_Number":"ADM/J/0283"},{"Surname":"MBONU","Firstname":"MMESOMA","CA":32,"Exam":45,"Admin_Number":"ADM/J/0285"},{"Surname":"NWONU","Firstname":"DAVID","CA":27,"Exam":41,"Admin_Number":"ADM/J/0260"},{"Surname":"OBI","Firstname":"LUCIA","CA":20,"Exam":26,"Admin_Number":"ADM/J/0289"},{"Surname":"ODOZOR","Firstname":"AUSTIN","CA":19,"Exam":29,"Admin_Number":"ADM/J/0249"},{"Surname":"OLAWALE","Firstname":"MOYINOLUWA","CA":29,"Admin_Number":"ADM/J/0290"},{"Surname":"OKERENITE","Firstname":"SPLENDID","Exam":53,"Admin_Number":"ADM/J/0287"},{"Surname":"OKUSHI","Firstname":"DANIEL","CA":32,"Exam":"x","Admin_Number":"ADM/J/0288"},{"Surname":"DABRINZE","Firstname":"POSSIBLE","CA":"y","Exam":40,"Admin_Number":"ADM/J/0250"}],"Second Term":[],"Third Term":[],"Class Info":[{"Class_Name":"JS2 Goodness","Subject":"BST (Information Tech.)"}],"ID":[{"Id":"Subjects","Start_Row":3}]}],"filenames":["subject_ict.xlsx"],"students":[{"Students Data":[{"Surname":"ADEOLA","Firstname":"TOLUWALASE","House":"Green","Admin_Number":"AND/J/0271","DOB":"26 FEB 2010","Sex":"M","Times_Present":126,"Override_Teacher_Comment":"very naughty","Override_Skills_Musical":3,"Override_Skills_Painting":4,"Override_Skills_Craft":3,"Override_Skills_Tools":3,"Override_Skills_Fluency":4,"Override_Sports_Indoor":4,"Override_Sports_Ball":4,"Override_Sports_Combative":3,"Override_Sports_Track":3,"Override_Sports_Gymnastics":4,"Override_Curricular_Jets":5,"Override_Curricular_Farmers":3,"Override_Curricular_Debating":4,"Override_Curricular_Homemaker":5,"Override_Curricular_Drama":5,"Override_Curricular_Voluntary":4,"Override_Curricular_Others":3,"Override_Behaviour_Reliability":5,"Override_Behaviour_Neatness":5,"Override_Behaviour_Politeness":5,"Override_Behaviour_Honesty":5,"Override_Behaviour_Creativity":4,"Override_Behaviour_Leadership":5,"Override_Behaviour_Spirituality":5,"Override_Behaviour_Cooporation":5},{"Surname":"ADEMOLA","Firstname":"SAMUEL","House":"Green","Admin_Number":"ADM/J/0273","DOB":"27 MAY 2009","Sex":"M","Times_Present":126},{"Surname":"AGBONIRO","Firstname":"JESSE","House":"Red","Admin_Number":"ADM/J/0284","DOB":"9 SEPT 2010","Sex":"M","Times_Present":126},{"Surname":"AJAYI","Firstname":"ABIGAIL","House":"Green","Admin_Number":"ADM/J/0269","DOB":"JUNE 2010","Sex":"F","Times_Present":120},{"Surname":"AKANDE","Firstname":"MICHAEL","House":"Red","Admin_Number":"ADM/J/0267","DOB":"29 DEC 2010","Sex":"M","Times_Present":126},{"Surname":"AKINTOKUN","Firstname":"MOFE","House":"Yellow","Admin_Number":"ADM/J/0272","DOB":"21 JULY 2010","Sex":"M","Times_Present":126},{"Surname":"ARTHUR","Firstname":"DESTINY","House":"Green","Admin_Number":"ADM/J/0266","DOB":"23 AUG 2009","Sex":"M","Times_Present":126},{"Surname":"AYANWENU","Firstname":"AKOREDE","House":"Blue","Admin_Number":"ADM/J/0270","DOB":"17 MAY 2010","Sex":"F","Times_Present":126},{"Surname":"BETHEL","Firstname":"MOYINULUWA","House":"Blue","Admin_Number":"ADM/J/0274","DOB":"13 MAR 2010","Sex":"F","Times_Present":126},{"Surname":"CHIJIOKE","Firstname":"JOY","House":"Yellow","Admin_Number":"ADM/J/0276","DOB":"27 FEB 2010","Sex":"F","Times_Present":126},{"Surname":"CHINWUBA","Firstname":"CHARLES","House":"Yellow","Admin_Number":"ADM/J/0275","DOB":"15 MAY 2010","Sex":"M","Times_Present":122},{"Surname":"DAVID","Firstname":"BEST","House":"Yellow","Admin_Number":"ADM/J/0277","DOB":"3 MAR 2010","Sex":"F","Times_Present":126},{"Surname":"DUYILE","Firstname":"IFEOLUWA","House":"Green","Admin_Number":"ADM/J/0256","DOB":"8 JAN 2010","Sex":"M","Times_Present":126},{"Surname":"EZEADILI","Firstname":"CHIBUNDU","House":"Yellow","Admin_Number":"ADM/J/0278","DOB":"14 FEB 2010","Sex":"M","Times_Present":126},{"Surname":"FAGITE","Firstname":"TOBILOBA","House":"Blue","Admin_Number":"ADM/J/0279","DOB":"26 AUG 2010","Sex":"M","Times_Present":126},{"Surname":"IDOGEN","Firstname":"EHIZOFUA","House":"Blue","Admin_Number":"ADM/J/0282","DOB":"6 JUNE 2010","Sex":"F","Times_Present":126},{"Surname":"IFADA","Firstname":"HOSSONA","House":"Red","Admin_Number":"ADM/J/0255","DOB":"12 OCT 2010","Sex":"M","Times_Present":126},{"Surname":"IHEDIOHA","Firstname":"DELIGHT","House":"Green","Admin_Number":"ADM/J/0280","DOB":"4 NOV 2010","Sex":"M","Times_Present":126},{"Surname":"JOSIAH","Firstname":"MATTHEW","House":"Red","Admin_Number":"ADM/J/0283","DOB":"13 AUG 2010","Sex":"F","Times_Present":126},{"Surname":"MBONU","Firstname":"MMESOMA","House":"Green","Admin_Number":"ADM/J/0285","DOB":"17 MAY 2009","Sex":"F","Times_Present":126},{"Surname":"NWONU","Firstname":"DAVID","House":"Yellow","Admin_Number":"ADM/J/0260","DOB":"29 AUG 2010","Sex":"M","Times_Present":124},{"Surname":"OBI","Firstname":"LUCIA","House":"Red","Admin_Number":"ADM/J/0289","DOB":"29 DEC 2010","Sex":"F","Times_Present":126},{"Surname":"ODOZOR","Firstname":"AUSTIN","House":"Green","Admin_Number":"ADM/J/0249","DOB":"9 AUG 2008","Sex":"M","Times_Present":126},{"Surname":"OLAWALE","Firstname":"MOYINOLUWA","House":"Red","Admin_Number":"ADM/J/0290","DOB":"19 SEP 2010","Sex":"F","Times_Present":108},{"Surname":"OKERENITE","Firstname":"SPLENDID","House":"Green","Admin_Number":"ADM/J/0287","DOB":"14 DEC 2009","Sex":"M","Times_Present":126},{"Surname":"OKUSHI","Firstname":"DANIEL","House":"Blue","Admin_Number":"ADM/J/0288","DOB":"29 SEP 2010","Sex":"M","Times_Present":126},{"Surname":"DABRINZE","Firstname":"POSSIBLE","House":"Yellow","Admin_Number":"ADM/J/0250","DOB":"20 JUN 2010","Sex":"M","Times_Present":126}],"Class Info":[{"Class_Name":"JS2 Goodness","School":"Junior Secondary","Session":"2021/2022","Times_School_Opened":126,"Next_Term_Begins":"4th January, 2022"}],"Settings":[{"Id_By_Admin_No":"Yes","First_Term_Active":"Yes","Second_Term_Active":"No","Third_Term_Active":"No","Students_Photos":"Yes","Verify":"Yes"}],"ID":[{"Id":"Students","Start_Row":3}]}],"keys":[{"Junior Grade Keys":[{"Grade_Name":"A","Min_Value":70,"Max_Value":100},{"Grade_Name":"B","Min_Value":60,"Max_Value":69.9},{"Grade_Name":"C","Min_Value":50,"Max_Value":59.9},{"Grade_Name":"P","Min_Value":40,"Max_Value":49.9},{"Grade_Name":"F","Min_Value":0,"Max_Value":39.9}],"Senior Grade Keys":[{"Grade_Name":"A","Min_Value":75,"Max_Value":100},{"Grade_Name":"B2","Min_Value":70,"Max_Value":74.9},{"Grade_Name":"B3","Min_Value":65,"Max_Value":69.9},{"Grade_Name":"C4","Min_Value":60,"Max_Value":64.9},{"Grade_Name":"C5","Min_Value":55,"Max_Value":59.9},{"Grade_Name":"C6","Min_Value":50,"Max_Value":54.9},{"Grade_Name":"D7","Min_Value":45,"Max_Value":49.9},{"Grade_Name":"E8","Min_Value":40,"Max_Value":44.9},{"Grade_Name":"F9","Min_Value":0,"Max_Value":39.9}],"Rating Keys":[{"Rating_Name":"Skill","Min_Value":2,"Max_Value":5},{"Rating_Name":"Sports","Min_Value":2,"Max_Value":5},{"Rating_Name":"Curricular","Min_Value":2,"Max_Value":5},{"Rating_Name":"Behaviour","Min_Value":2,"Max_Value":5}],"School Info":[{"School_Name":"SAMUEL ADEGBITE ANGLICAN COLLEGE","Extra_Info":"(A Day-Co-educational Institution Of The Anglican Diocese Of Lagos West)","Address":"St. Peters Anglican Church, Ikotun Road, Idumu, Lagos.","Title":"SECONDARY SCHOOL STUDENT'S INTERNAL ACADEMIC REPORT SHEET","Watermark":"SAMUEL ADEGBITE ANGLICAN COLLEGE"},{"Address":null,"Title":null},{"Address":null,"Title":null},{"Address":null,"Title":null}],"ID":[{"Id":"DON'T CHANGE!!!","Start_Row":null},{"Id":"File ID","Start_Row":"Start Row"},{"Id":"Keys","Start_Row":1},{"Id":null}]}],"pool":[{"Principal Comment":[{"Pool":"Good performance, keep it up"},{"Pool":"A wonderful performance, keep it up"},{"Pool":"A highly impressive result, keep it up"},{"Pool":"Good result but you need to improve in your weak area(s)"},{"Pool":"Average result, there is still room for improvement"},{"Pool":"Average result, you can still do better"},{"Pool":"A fair result, you really need to improve in your weak subject(s)"},{"Pool":"Weak performance, you really need to improve in your weak subjects"},{"Pool":"A very good performance, keep it up"},{"Pool":"Beautiful performance, keep the flag flying"},{"Pool":"Weak result, you need to concentrate more on your studies"},{"Pool":"Excellent performance, keep it up"},{"Pool":"A brilliant performance, keep it up"},{"Pool":"Good result, there is room for improvement"},{"Pool":"An average result, you really need to study harder"},{"Pool":"A very good result, weldone."},{"Pool":"A beautiful result, keep it up"},{"Pool":"An impressive result, keep it up"},{"Pool":"A very good performance, keep the flag flying"},{"Pool":"An average result, there is still room for improvement,"},{"Pool":"A fair result, you can still do better."},{"Pool":"A weak result, there is room for you to work harder."},{"Pool":"A very weak performance, you seriously need to work harder."},{"Pool":"Poor performance, your need to work on your weak subjects"},{"Pool":"Excellent performance, keep it up."},{"Pool":null}],"Teacher Comment":[{"Pool":"Always willing to take up responsiblities"},{"Pool":"Very friendly and humorous"},{"Pool":"A highly talented student"},{"Pool":"Very hardworking and conscioustious"},{"Pool":"Friendly but needs to put in more efforts"},{"Pool":"Easy-going and very neat"},{"Pool":"Always punctual to class and all other activities"},{"Pool":"Highly dependable and trustworthy"},{"Pool":"Very reliable and hardworking"},{"Pool":"Active and always willing to take up responsibilities"},{"Pool":"Friendly but needs to pay more attention to his/her studies"},{"Pool":"Friendly but needs to settle down for serious work"},{"Pool":"Easy-going but needs to be more punctual"},{"Pool":"Very studious and always attentive in class"},{"Pool":"Very reliable and willing to assist others"},{"Pool":"Highly cooperative and dependable"},{"Pool":"Friendly but needs to be less playful"},{"Pool":"Friendly but restless, needs to always observe siesta"},{"Pool":"Highly organized and conscientious"},{"Pool":"Friendly and highly willing to learn"},{"Pool":"A consistent and handworking student"},{"Pool":"Very reliable and ready to take to correction"},{"Pool":null},{"Pool":null},{"Pool":null}],"Skills":[{"Pool":"Musical Instrument"},{"Pool":"Drawing and Painting"},{"Pool":"Craft"},{"Pool":"Handling of Workshop Tools"},{"Pool":"Handwriting/Fluency"}],"Sports":[{"Pool":"Indoor Games"},{"Pool":"Ball Games"},{"Pool":"Combative Games"},{"Pool":"Track/Throws"},{"Pool":"Gymnastics"}],"Curricular":[{"Pool":"JETS"},{"Pool":"Young Farmers Club"},{"Pool":"Literary & Debating"},{"Pool":"Home Maker"},{"Pool":"Drama/Culture/Music/Craft"},{"Pool":"Voluntary Service Org."},{"Pool":"Others"}],"Behaviour":[{"Pool":"Reliability"},{"Pool":"Neatness"},{"Pool":"Politeness"},{"Pool":"Honesty"},{"Pool":"Initiative/Creativity"},{"Pool":"Leadership Role"},{"Pool":"Level of Spiritual Dev.","Override":3},{"Pool":"Spirit of Co-operation"}],"ID":[{"Id":"DON'T CHANGE!!!","Start_Row":null},{"Id":"File ID","Start_Row":"Start Row"},{"Id":"Pool","Start_Row":1}]}],"logo":null,"images":["stunt toy car.jpg"],"errors":[]}
我用你的数据试过你的代码,正如预期的那样,它遍历了所有 27 个项目。但是因为不满足某些条件,您正在为第 22 条记录设置 innError = true
,并且永远不会将其设置回 false
。
所以之后的所有项目都将被视为它们也有错误(这可能会让您相信它们没有被迭代)。只需尝试在内部循环中添加一个 console.log(j)
作为第一个语句。你会看到,它会打印出从 0
到 26
...
的所有值
[已修改] 这里可以提供一点帮助。 我 运行 遇到了 for 循环的问题。我有一个 for 循环嵌套在另一个中。外层循环只有 level 元素,而嵌套层只包含 27 个项目。 问题是安装程序在退出前只能 运行 通过嵌套数组的 22 项。
在服务器端 运行 设置,在 node.js 中完成。客户端是 React,它通过 websocket 与服务器通信。从控制台报告中,node.js 运行s 上述代码 3x;在所有这些时间里,只有 22 项超出了预期的 27 项。
加入 Repl 以获得完整的 Node.js 目录: https://replit.com/join/uabhesdiif-emexrevolarter
下面的代码。我感谢任何帮助。谢谢。
VerifyResult.js
let data = {};
let error = [];
let feedback = [];
if(typeof dataJson == 'string') {
data = JSON.parse(dataJson)
} else {
data = dataJson;
}
try {
// get variables
const getAvatarState = data.settings.isAvatar;
const getIdState = data.settings.isAdminId;
const getStudents = data.students[0]['Students Data'];
const getClassInfo = data.students[0]['Class Info'][0];
const getAvatars = data.images;
const getLogo = data.logo;
const getFilenames = data.filenames;
const getFirstTermState = data.settings.isFirstTerm;
const getSecondTermState = data.settings.isSecondTerm;
const getThirdTermState = data.settings.isThirdTerm;
const getSubjectList = data.subjects;
let getFirstTerm = [];
let getSecondTerm =[];
let getThirdTerm = [];
// verify #1: if avatars are permitted & same number of images included
if(getAvatarState == '1') {
if(getStudents.length > getAvatars.length) {
feedback.push(`${getAvatars.length} Images supplied for Avatar is lesser than the number of ${getStudents.length} students`);
feedback.push('Some Results may not include Avatar')
}
if(getStudents.length < getAvatars.length) {
feedback.push(`${getAvatars.length} Images supplied for Avatar is more than the number of ${getStudents.length} students`);
feedback.push('This may not pose any problem except possible mismatch')
}
} else {
feedback.push('Avatar will not be included in any result')
}
// verify #2: if logo is included
if(getLogo == null) {
feedback.push('No image was added as logo, and hence, will not be included')
}
// verify #3: if empty value for Admin Numbers, Names, in Students file
let idList = [];
let countItem = 0;
let innerCount = 0;
for(let k = 0; k < getStudents.length; k++) {
let d = getStudents[k];
countItem = k + 1;
let fName, lName;
if(getIdState == '1') {
if(d.Admin_Number != undefined && d.Admin_Number != '') {
idList.push(d.Admin_Number);
} else {
error.push(`Admin Number for Student at row "${countItem}" is empty, in Students workbook`)
}
}
if(d.Firstname != undefined && d.Firstname != '') {
fName = d.Firstname
} else {
error.push(`Firstname for Student at row "${countItem}" is empty, in Students workbook`)
}
if(d.Surname != undefined && d.Surname != '') {
lName = d.Surname
} else {
error.push(`Surname for Student at row "${countItem}" is empty, in Students workbook`)
}
if(fName != undefined && lName != undefined) {
(getIdState == '0') && idList.push(`${lName}/${fName}`);
}
};
// verify #4: if IDs for Students file is unique
if(!IsArrayUnique(idList)) {
(getIdState == '1') && error.push(`One or Student Admin Numbers are not unique, in Students file`);
(getIdState == '0') && error.push(`One or more Student names are not unique, in Students file`);
}
// verify #5: if empty value for Class Info, in Students file
if(getClassInfo.Class_Name == undefined) {
error.push('Class Name of Class Info worksheet is empty, in Students file')
}
if(getClassInfo.School == undefined) {
error.push('School Name of Class Info worksheet is empty, in Students file')
}
if(getClassInfo.Session == undefined) {
error.push('Session of Class Info worksheet is empty, in Students file')
}
if(getClassInfo.Times_School_Opened == undefined) {
error.push('No of Times School Opened of Class Info worksheet is empty, in Students file')
}
countItem = 0;
for(let i = 0; i < getSubjectList.length; i++) {
let sub = getSubjectList[i];
let gFile = getFilenames[i];
countItem = i + 1;
let innError = false;
let list = [];
let subj, fName, lName, sName, termName;
if(getFirstTermState == '1') {
// verify #6: if empty value in Subject files for First Term
innError = false;
termName = 'First Term';
subj = sub['First Term'];
if(sub['Class Info'][0].Class_Name == undefined) {
innError = true;
error.push(`Class Name in ${gFile} is empty`)
}
if(sub['Class Info'][0].Subject == undefined) {
innError = true;
error.push(`Subject Name in ${gFile} is empty`)
}
if(subj < 1) {
innError = true;
error.push(`Subject scores for ${termName} cannot be found in ${gFile}`)
}
if(!innError) {
console.log('==== STUDENTS TOTAL: ', subj.length);
innerCount = 0;
for(let j = 0; j < subj.length; j++) {
let item = subj[j];
innerCount = j + 1;
if(item.Surname == undefined) {
innError = true;
error.push(`Surname for a Student at row ${innerCount} is empty, for ${termName} in ${gFile}`)
}
if(item.Firstname == undefined) {
innError = true;
error.push(`Firstname for a Student at row ${innerCount} is empty, for ${termName} in ${gFile}`)
}
if(item.Admin_Number == undefined && getIdState == '1') {
innError = true;
error.push(`Admin Number for a Student at row ${innerCount} is empty, for ${termName} in ${gFile}`)
}
if(!innError) {
fName = item.Firstname;
lName = item.Surname;
if(item.CA == undefined && !innError) {
innError = true;
error.push(`CA for "${lName} ${fName}" at row ${innerCount} is empty, for ${termName} in ${gFile}`)
}
if(item.Exam == undefined && !innError) {
innError = true;
error.push(`Exam for "${lName} ${fName}" at row ${innerCount} is empty, for ${termName} in ${gFile}`)
}
}
// verify #7: if both CA & Exam are numbers for First Term
if(!innError) {
console.log('====== TOTAL READ: ', innerCount + ' | ' + countItem);
console.log('====== IS CA A NUMBER?: ', item.CA + ' | ' + IsNumber(item.CA));
console.log('====== IS Exam A NUMBER?: ', item.Exam + ' | ' + IsNumber(item.Exam));
if(!IsNumber(item.CA)) {
innError = true;
error.push(`CA for "${lName} ${fName}" at row ${innerCount} is not a number (${item.CA}), for ${termName} in ${gFile}`)
}
if(!IsNumber(item.Exam)) {
innError = true;
error.push(`Exam for "${lName} ${fName}" at row ${innerCount} is not a number (${item.Exam}), for ${termName} in ${gFile}`)
}
}
// verify #8: if Total is > 45 & < 50
if(!innError) {
const itemTotal = Number(item.CA) + Number(item.Exam);
if(itemTotal > 45 && itemTotal < 50) {
innError = true;
error.push(`The CA (CA: ${item.CA}; Exam: ${item.Exam}; Total: ${itemTotal}) for "${lName} ${fName}" at row ${innerCount}, should be upgraded to 50, for ${termName} in ${gFile}`)
}
}
if(!innError) {
if(getIdState == '1'){
sName = item.Admin_Number;
list.push(sName);
} else {
sName = lName + '/' + fName;
list.push(`${sName}`);
}
// verify #9: match IDs as Admin Number or Names for First Term
if(idList.indexOf(sName) === -1) {
innError = true;
(getIdState == '1') && error.push(`Student Admin Number "${sName}" is mismatched, for ${termName} in ${gFile}`);
(getIdState == '0') && error.push(`Student name "${lName} ${fName}" is mismatched, for ${termName} in ${gFile}`);
}
}
}
// verify #10: if unique IDs for First Term
if(!innError) {
if(idList.length == list.length) {
if(!IsArrayUnique(list)){
innError = true;
(getIdState == '1') && error.push(`One or more Student Admin Numbers are not unique, for ${termName} in ${gFile}`)
(getIdState == '0') && error.push(`One or more Student names are not unique, for ${termName} in ${gFile}`);
}
} else {
innError = true;
error.push(`Found ${list.length} Students against expected ${idList.length} number of Students, for ${termName} in ${gFile}`)
}
}
}
}
}
// verify #3: match admin Id is set as active, else match students names
} catch (err) {
error.push(err)
}
const res = {
data: data,
error: error,
feedback: feedback
}
data.json
{"settings":{"isAdminId":"1","isFirstTerm":"1","isSecondTerm":"0","isThirdTerm":"0","isAvatar":"1","isVerify":"1"},"subjects":[{"First Term":[{"Surname":"ADEOLA","Firstname":"TOLUWALASE","CA":38,"Exam":56,"Admin_Number":"AND/J/0271"},{"Surname":"ADEMOLA","Firstname":"SAMUEL","CA":35,"Exam":55,"Admin_Number":"ADM/J/0273"},{"Surname":"AGBONIRO","Firstname":"JESSE","CA":40,"Exam":54,"Admin_Number":"ADM/J/0284"},{"Surname":"AJAYI","Firstname":"ABIGAIL","CA":23,"Exam":33,"Admin_Number":"ADM/J/0269"},{"Surname":"AKANDE","Firstname":"MICHAEL","CA":29,"Exam":41,"Admin_Number":"ADM/J/0267"},{"Surname":"AKINTOKUN","Firstname":"MOFE","CA":27,"Exam":47,"Admin_Number":"ADM/J/0272"},{"Surname":"ARTHUR","Firstname":"DESTINY","CA":33,"Exam":55,"Admin_Number":"ADM/J/0266"},{"Surname":"AYANWENU","Firstname":"AKOREDE","CA":22,"Exam":35,"Admin_Number":"ADM/J/0270"},{"Surname":"BETHEL","Firstname":"MOYINULUWA","CA":40,"Exam":58,"Admin_Number":"ADM/J/0274"},{"Surname":"CHIJIOKE","Firstname":"JOY","CA":26,"Exam":44,"Admin_Number":"ADM/J/0276"},{"Surname":"CHINWUBA","Firstname":"CHARLES","CA":33,"Exam":40,"Admin_Number":"ADM/J/0275"},{"Surname":"DAVID","Firstname":"BEST","CA":40,"Exam":59,"Admin_Number":"ADM/J/0277"},{"Surname":"DUYILE","Firstname":"IFEOLUWA","CA":29,"Exam":41,"Admin_Number":"ADM/J/0256"},{"Surname":"EZEADILI","Firstname":"CHIBUNDU","CA":35,"Exam":49,"Admin_Number":"ADM/J/0278"},{"Surname":"FAGITE","Firstname":"TOBILOBA","CA":40,"Exam":57,"Admin_Number":"ADM/J/0279"},{"Surname":"IDOGEN","Firstname":"EHIZOFUA","CA":31,"Exam":51,"Admin_Number":"ADM/J/0282"},{"Surname":"IFADA","Firstname":"HOSSONA","CA":33,"Exam":50,"Admin_Number":"ADM/J/0255"},{"Surname":"IHEDIOHA","Firstname":"DELIGHT","CA":34,"Exam":53,"Admin_Number":"ADM/J/0280"},{"Surname":"JOSIAH","Firstname":"MATTHEW","CA":29,"Exam":49,"Admin_Number":"ADM/J/0283"},{"Surname":"MBONU","Firstname":"MMESOMA","CA":32,"Exam":45,"Admin_Number":"ADM/J/0285"},{"Surname":"NWONU","Firstname":"DAVID","CA":27,"Exam":41,"Admin_Number":"ADM/J/0260"},{"Surname":"OBI","Firstname":"LUCIA","CA":20,"Exam":26,"Admin_Number":"ADM/J/0289"},{"Surname":"ODOZOR","Firstname":"AUSTIN","CA":19,"Exam":29,"Admin_Number":"ADM/J/0249"},{"Surname":"OLAWALE","Firstname":"MOYINOLUWA","CA":29,"Admin_Number":"ADM/J/0290"},{"Surname":"OKERENITE","Firstname":"SPLENDID","Exam":53,"Admin_Number":"ADM/J/0287"},{"Surname":"OKUSHI","Firstname":"DANIEL","CA":32,"Exam":"x","Admin_Number":"ADM/J/0288"},{"Surname":"DABRINZE","Firstname":"POSSIBLE","CA":"y","Exam":40,"Admin_Number":"ADM/J/0250"}],"Second Term":[],"Third Term":[],"Class Info":[{"Class_Name":"JS2 Goodness","Subject":"BST (Information Tech.)"}],"ID":[{"Id":"Subjects","Start_Row":3}]}],"filenames":["subject_ict.xlsx"],"students":[{"Students Data":[{"Surname":"ADEOLA","Firstname":"TOLUWALASE","House":"Green","Admin_Number":"AND/J/0271","DOB":"26 FEB 2010","Sex":"M","Times_Present":126,"Override_Teacher_Comment":"very naughty","Override_Skills_Musical":3,"Override_Skills_Painting":4,"Override_Skills_Craft":3,"Override_Skills_Tools":3,"Override_Skills_Fluency":4,"Override_Sports_Indoor":4,"Override_Sports_Ball":4,"Override_Sports_Combative":3,"Override_Sports_Track":3,"Override_Sports_Gymnastics":4,"Override_Curricular_Jets":5,"Override_Curricular_Farmers":3,"Override_Curricular_Debating":4,"Override_Curricular_Homemaker":5,"Override_Curricular_Drama":5,"Override_Curricular_Voluntary":4,"Override_Curricular_Others":3,"Override_Behaviour_Reliability":5,"Override_Behaviour_Neatness":5,"Override_Behaviour_Politeness":5,"Override_Behaviour_Honesty":5,"Override_Behaviour_Creativity":4,"Override_Behaviour_Leadership":5,"Override_Behaviour_Spirituality":5,"Override_Behaviour_Cooporation":5},{"Surname":"ADEMOLA","Firstname":"SAMUEL","House":"Green","Admin_Number":"ADM/J/0273","DOB":"27 MAY 2009","Sex":"M","Times_Present":126},{"Surname":"AGBONIRO","Firstname":"JESSE","House":"Red","Admin_Number":"ADM/J/0284","DOB":"9 SEPT 2010","Sex":"M","Times_Present":126},{"Surname":"AJAYI","Firstname":"ABIGAIL","House":"Green","Admin_Number":"ADM/J/0269","DOB":"JUNE 2010","Sex":"F","Times_Present":120},{"Surname":"AKANDE","Firstname":"MICHAEL","House":"Red","Admin_Number":"ADM/J/0267","DOB":"29 DEC 2010","Sex":"M","Times_Present":126},{"Surname":"AKINTOKUN","Firstname":"MOFE","House":"Yellow","Admin_Number":"ADM/J/0272","DOB":"21 JULY 2010","Sex":"M","Times_Present":126},{"Surname":"ARTHUR","Firstname":"DESTINY","House":"Green","Admin_Number":"ADM/J/0266","DOB":"23 AUG 2009","Sex":"M","Times_Present":126},{"Surname":"AYANWENU","Firstname":"AKOREDE","House":"Blue","Admin_Number":"ADM/J/0270","DOB":"17 MAY 2010","Sex":"F","Times_Present":126},{"Surname":"BETHEL","Firstname":"MOYINULUWA","House":"Blue","Admin_Number":"ADM/J/0274","DOB":"13 MAR 2010","Sex":"F","Times_Present":126},{"Surname":"CHIJIOKE","Firstname":"JOY","House":"Yellow","Admin_Number":"ADM/J/0276","DOB":"27 FEB 2010","Sex":"F","Times_Present":126},{"Surname":"CHINWUBA","Firstname":"CHARLES","House":"Yellow","Admin_Number":"ADM/J/0275","DOB":"15 MAY 2010","Sex":"M","Times_Present":122},{"Surname":"DAVID","Firstname":"BEST","House":"Yellow","Admin_Number":"ADM/J/0277","DOB":"3 MAR 2010","Sex":"F","Times_Present":126},{"Surname":"DUYILE","Firstname":"IFEOLUWA","House":"Green","Admin_Number":"ADM/J/0256","DOB":"8 JAN 2010","Sex":"M","Times_Present":126},{"Surname":"EZEADILI","Firstname":"CHIBUNDU","House":"Yellow","Admin_Number":"ADM/J/0278","DOB":"14 FEB 2010","Sex":"M","Times_Present":126},{"Surname":"FAGITE","Firstname":"TOBILOBA","House":"Blue","Admin_Number":"ADM/J/0279","DOB":"26 AUG 2010","Sex":"M","Times_Present":126},{"Surname":"IDOGEN","Firstname":"EHIZOFUA","House":"Blue","Admin_Number":"ADM/J/0282","DOB":"6 JUNE 2010","Sex":"F","Times_Present":126},{"Surname":"IFADA","Firstname":"HOSSONA","House":"Red","Admin_Number":"ADM/J/0255","DOB":"12 OCT 2010","Sex":"M","Times_Present":126},{"Surname":"IHEDIOHA","Firstname":"DELIGHT","House":"Green","Admin_Number":"ADM/J/0280","DOB":"4 NOV 2010","Sex":"M","Times_Present":126},{"Surname":"JOSIAH","Firstname":"MATTHEW","House":"Red","Admin_Number":"ADM/J/0283","DOB":"13 AUG 2010","Sex":"F","Times_Present":126},{"Surname":"MBONU","Firstname":"MMESOMA","House":"Green","Admin_Number":"ADM/J/0285","DOB":"17 MAY 2009","Sex":"F","Times_Present":126},{"Surname":"NWONU","Firstname":"DAVID","House":"Yellow","Admin_Number":"ADM/J/0260","DOB":"29 AUG 2010","Sex":"M","Times_Present":124},{"Surname":"OBI","Firstname":"LUCIA","House":"Red","Admin_Number":"ADM/J/0289","DOB":"29 DEC 2010","Sex":"F","Times_Present":126},{"Surname":"ODOZOR","Firstname":"AUSTIN","House":"Green","Admin_Number":"ADM/J/0249","DOB":"9 AUG 2008","Sex":"M","Times_Present":126},{"Surname":"OLAWALE","Firstname":"MOYINOLUWA","House":"Red","Admin_Number":"ADM/J/0290","DOB":"19 SEP 2010","Sex":"F","Times_Present":108},{"Surname":"OKERENITE","Firstname":"SPLENDID","House":"Green","Admin_Number":"ADM/J/0287","DOB":"14 DEC 2009","Sex":"M","Times_Present":126},{"Surname":"OKUSHI","Firstname":"DANIEL","House":"Blue","Admin_Number":"ADM/J/0288","DOB":"29 SEP 2010","Sex":"M","Times_Present":126},{"Surname":"DABRINZE","Firstname":"POSSIBLE","House":"Yellow","Admin_Number":"ADM/J/0250","DOB":"20 JUN 2010","Sex":"M","Times_Present":126}],"Class Info":[{"Class_Name":"JS2 Goodness","School":"Junior Secondary","Session":"2021/2022","Times_School_Opened":126,"Next_Term_Begins":"4th January, 2022"}],"Settings":[{"Id_By_Admin_No":"Yes","First_Term_Active":"Yes","Second_Term_Active":"No","Third_Term_Active":"No","Students_Photos":"Yes","Verify":"Yes"}],"ID":[{"Id":"Students","Start_Row":3}]}],"keys":[{"Junior Grade Keys":[{"Grade_Name":"A","Min_Value":70,"Max_Value":100},{"Grade_Name":"B","Min_Value":60,"Max_Value":69.9},{"Grade_Name":"C","Min_Value":50,"Max_Value":59.9},{"Grade_Name":"P","Min_Value":40,"Max_Value":49.9},{"Grade_Name":"F","Min_Value":0,"Max_Value":39.9}],"Senior Grade Keys":[{"Grade_Name":"A","Min_Value":75,"Max_Value":100},{"Grade_Name":"B2","Min_Value":70,"Max_Value":74.9},{"Grade_Name":"B3","Min_Value":65,"Max_Value":69.9},{"Grade_Name":"C4","Min_Value":60,"Max_Value":64.9},{"Grade_Name":"C5","Min_Value":55,"Max_Value":59.9},{"Grade_Name":"C6","Min_Value":50,"Max_Value":54.9},{"Grade_Name":"D7","Min_Value":45,"Max_Value":49.9},{"Grade_Name":"E8","Min_Value":40,"Max_Value":44.9},{"Grade_Name":"F9","Min_Value":0,"Max_Value":39.9}],"Rating Keys":[{"Rating_Name":"Skill","Min_Value":2,"Max_Value":5},{"Rating_Name":"Sports","Min_Value":2,"Max_Value":5},{"Rating_Name":"Curricular","Min_Value":2,"Max_Value":5},{"Rating_Name":"Behaviour","Min_Value":2,"Max_Value":5}],"School Info":[{"School_Name":"SAMUEL ADEGBITE ANGLICAN COLLEGE","Extra_Info":"(A Day-Co-educational Institution Of The Anglican Diocese Of Lagos West)","Address":"St. Peters Anglican Church, Ikotun Road, Idumu, Lagos.","Title":"SECONDARY SCHOOL STUDENT'S INTERNAL ACADEMIC REPORT SHEET","Watermark":"SAMUEL ADEGBITE ANGLICAN COLLEGE"},{"Address":null,"Title":null},{"Address":null,"Title":null},{"Address":null,"Title":null}],"ID":[{"Id":"DON'T CHANGE!!!","Start_Row":null},{"Id":"File ID","Start_Row":"Start Row"},{"Id":"Keys","Start_Row":1},{"Id":null}]}],"pool":[{"Principal Comment":[{"Pool":"Good performance, keep it up"},{"Pool":"A wonderful performance, keep it up"},{"Pool":"A highly impressive result, keep it up"},{"Pool":"Good result but you need to improve in your weak area(s)"},{"Pool":"Average result, there is still room for improvement"},{"Pool":"Average result, you can still do better"},{"Pool":"A fair result, you really need to improve in your weak subject(s)"},{"Pool":"Weak performance, you really need to improve in your weak subjects"},{"Pool":"A very good performance, keep it up"},{"Pool":"Beautiful performance, keep the flag flying"},{"Pool":"Weak result, you need to concentrate more on your studies"},{"Pool":"Excellent performance, keep it up"},{"Pool":"A brilliant performance, keep it up"},{"Pool":"Good result, there is room for improvement"},{"Pool":"An average result, you really need to study harder"},{"Pool":"A very good result, weldone."},{"Pool":"A beautiful result, keep it up"},{"Pool":"An impressive result, keep it up"},{"Pool":"A very good performance, keep the flag flying"},{"Pool":"An average result, there is still room for improvement,"},{"Pool":"A fair result, you can still do better."},{"Pool":"A weak result, there is room for you to work harder."},{"Pool":"A very weak performance, you seriously need to work harder."},{"Pool":"Poor performance, your need to work on your weak subjects"},{"Pool":"Excellent performance, keep it up."},{"Pool":null}],"Teacher Comment":[{"Pool":"Always willing to take up responsiblities"},{"Pool":"Very friendly and humorous"},{"Pool":"A highly talented student"},{"Pool":"Very hardworking and conscioustious"},{"Pool":"Friendly but needs to put in more efforts"},{"Pool":"Easy-going and very neat"},{"Pool":"Always punctual to class and all other activities"},{"Pool":"Highly dependable and trustworthy"},{"Pool":"Very reliable and hardworking"},{"Pool":"Active and always willing to take up responsibilities"},{"Pool":"Friendly but needs to pay more attention to his/her studies"},{"Pool":"Friendly but needs to settle down for serious work"},{"Pool":"Easy-going but needs to be more punctual"},{"Pool":"Very studious and always attentive in class"},{"Pool":"Very reliable and willing to assist others"},{"Pool":"Highly cooperative and dependable"},{"Pool":"Friendly but needs to be less playful"},{"Pool":"Friendly but restless, needs to always observe siesta"},{"Pool":"Highly organized and conscientious"},{"Pool":"Friendly and highly willing to learn"},{"Pool":"A consistent and handworking student"},{"Pool":"Very reliable and ready to take to correction"},{"Pool":null},{"Pool":null},{"Pool":null}],"Skills":[{"Pool":"Musical Instrument"},{"Pool":"Drawing and Painting"},{"Pool":"Craft"},{"Pool":"Handling of Workshop Tools"},{"Pool":"Handwriting/Fluency"}],"Sports":[{"Pool":"Indoor Games"},{"Pool":"Ball Games"},{"Pool":"Combative Games"},{"Pool":"Track/Throws"},{"Pool":"Gymnastics"}],"Curricular":[{"Pool":"JETS"},{"Pool":"Young Farmers Club"},{"Pool":"Literary & Debating"},{"Pool":"Home Maker"},{"Pool":"Drama/Culture/Music/Craft"},{"Pool":"Voluntary Service Org."},{"Pool":"Others"}],"Behaviour":[{"Pool":"Reliability"},{"Pool":"Neatness"},{"Pool":"Politeness"},{"Pool":"Honesty"},{"Pool":"Initiative/Creativity"},{"Pool":"Leadership Role"},{"Pool":"Level of Spiritual Dev.","Override":3},{"Pool":"Spirit of Co-operation"}],"ID":[{"Id":"DON'T CHANGE!!!","Start_Row":null},{"Id":"File ID","Start_Row":"Start Row"},{"Id":"Pool","Start_Row":1}]}],"logo":null,"images":["stunt toy car.jpg"],"errors":[]}
我用你的数据试过你的代码,正如预期的那样,它遍历了所有 27 个项目。但是因为不满足某些条件,您正在为第 22 条记录设置 innError = true
,并且永远不会将其设置回 false
。
所以之后的所有项目都将被视为它们也有错误(这可能会让您相信它们没有被迭代)。只需尝试在内部循环中添加一个 console.log(j)
作为第一个语句。你会看到,它会打印出从 0
到 26
...