- 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.
38 lines
966 B
JavaScript
38 lines
966 B
JavaScript
const scores = [58, 76, 91, 84];
|
|
const students = [
|
|
{ name: "小周", finished: true },
|
|
{ name: "小林", finished: true },
|
|
{ name: "小陈", finished: false },
|
|
];
|
|
|
|
const scoreLabels = scores.map(function (score) {
|
|
return `${score}分`;
|
|
});
|
|
|
|
const passedScores = scores.filter(function (score) {
|
|
return score >= 60;
|
|
});
|
|
|
|
const totalScore = scores.reduce(function (total, score) {
|
|
return total + score;
|
|
}, 0);
|
|
|
|
const topScore = scores.find(function (score) {
|
|
return score >= 90;
|
|
});
|
|
|
|
const hasFailedScore = scores.some(function (score) {
|
|
return score < 60;
|
|
});
|
|
|
|
const allFinished = students.every(function (student) {
|
|
return student.finished === true;
|
|
});
|
|
|
|
console.log("带单位成绩:", scoreLabels);
|
|
console.log("及格成绩:", passedScores);
|
|
console.log("总分:", totalScore);
|
|
console.log("第一个 90 分以上:", topScore);
|
|
console.log("是否存在不及格:", hasFailedScore);
|
|
console.log("是否全部完成:", allFinished);
|