这是我的代码
function howManySundays(num,startDay){
let Days = ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"];
for(let i = 0 ; i < num ;i++){
var value = [];
value.push(Days[i%7])
console.log(value)
}
}
howManySundays(9,"Sunday");
这是代码
的结果[ 'Monday' ]
[ 'Tuesday' ]
[ 'Wednesday' ]
[ 'Thursday' ]
[ 'Friday' ]
[ 'Saturday' ]
[ 'Sunday' ]
[ 'Monday' ]
[ 'Tuesday' ]
如何在数组中找到重复项?
答案 0 :(得分:0)
这会对你有帮助吗?
function howManySundays(num,startDay){
let Days = ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"];
let i = 0;
while (num > 0) {
console.log(i, Days[i])
i++;
if(i == 7) i = 0;
num--;
}
}
howManySundays(9,"Sunday")