- Implemented exercises for array high-order methods, memory and execution, switch statements, and final review. - Added starter and answer files for each exercise to facilitate learning. - Created a runner HTML file to execute JavaScript code and display console outputs. - Updated README files to include exercise objectives, tasks, and usage instructions.
42 lines
1.1 KiB
JavaScript
42 lines
1.1 KiB
JavaScript
const learningStatus = "review";
|
||
const records = ["变量", "条件", "函数", null, "对象"];
|
||
|
||
let optionalNote;
|
||
const finalComment = null;
|
||
let statusText = "";
|
||
const finishedRecords = [];
|
||
|
||
switch (learningStatus) {
|
||
case "basic":
|
||
statusText = "正在完成基础阶段";
|
||
break;
|
||
case "review":
|
||
statusText = "正在进入总复习";
|
||
break;
|
||
case "done":
|
||
statusText = "当前阶段已经完成";
|
||
break;
|
||
default:
|
||
statusText = "状态未知";
|
||
break;
|
||
}
|
||
|
||
console.log("状态说明:", statusText);
|
||
console.log("optionalNote:", optionalNote);
|
||
console.log("optionalNote 是否为 undefined:", optionalNote === undefined);
|
||
console.log("finalComment:", finalComment);
|
||
console.log("finalComment 是否为 null:", finalComment === null);
|
||
|
||
for (let index = 0; index < records.length; index += 1) {
|
||
const currentRecord = records[index];
|
||
|
||
if (currentRecord === undefined || currentRecord === null) {
|
||
console.log(`第 ${index + 1} 项为空值,停止读取。`);
|
||
break;
|
||
}
|
||
|
||
finishedRecords.push(currentRecord);
|
||
}
|
||
|
||
console.log("停止前已读取内容:", finishedRecords);
|