Files
charlie 877acb5a8f feat: Add JavaScript core exercises and solutions
- 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.
2026-03-13 11:09:19 +08:00

42 lines
1.1 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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