javascript - JavaScript 循环是否正确?
问题描述
我想遍历一个学生的每个时期,并找到在特定日期的特定时期有空的学生的名字。以下是我尝试过的方法,但它不起作用。下面给出了 MongoDB 的 JSON
正在工作的原始代码是:
const monday = await Timetable.find({ "monday.first": true })
let names = monday.map(a => a.name)
console.log(names)
{
"name" : "JOHN DOE",
"regNumber": "12345",
"monday": [{"first":true},{"second":true}],
"tuesday": [{"third":true},{"seventh":true}]
}
slots = . `[first,second,third,fourth,fifth,sixth,seventh,eight,ninth,tenth]
days = [monday,tuesday,wednesday,thursday,friday]
for(day in days){
for(slot in slots){
const day = await Timetable.find({"monday.slot":true})
let names = day.map(a=>a.name)
console.log("Students free in "+slot+" are: "+names)
}
}
但是我遇到了一个错误
解决方案
推荐阅读
- c# - 访问多对多连接实体的导航属性的属性
- javascript - Angular 中只允许一位小数和正数
- imap - NO [UNAVAILABLE] UID FETCH 服务器在获取消息时出错
- python - 奇怪的 Python 导入错误
- wpf - 如何在内容演示者中获取 UI 对象?
- jbpm - 将 YAWL 文件 (*.ywl) 迁移到 BPMN 2.0 模式文件
- flutter - Flutter 相机插件,用于转码和传输流到媒体服务器
- android - 如何停止视频通话会话?音频始终开启
- android - List 类型的解构声明初始化器
必须有一个“component6()”函数 - swift - 我怎样才能用阴影视图iOS swift实现这种角落redius?