class makeIterator { constructor(arr) { this.arr = arr this.i = 0; this.j = 0; } next() { if(this.i >= this.arr.length) return undefined let ans = this.arr[this.i][this.j]; this.j++; if(this.j >= this.arr[this.i].length) { this.i++; this.j = 0; } return ans; } } let m = new makeIterator([[1, 4, 7],[2, 9],[8, 7, 6, 3]]); console.log(m.next()); console.log(m.next());
点赞 1

相关推荐

码砖:求职岗位要突出,一眼就能看到,教育背景放到最后,学校经历没那么重要,项目要重点突出
点赞 评论 收藏
分享
06-07 00:00
已编辑
腾讯_后端开发
点赞 评论 收藏
分享
绝迹的星:前端和后端写两份简历, 如果想干全栈就直接写求职意向为全栈工程师
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务