所以我正在做一项任务,我现在难以置信地卡住了几步,直到完成。这是我到目前为止的代码,我需要做的是首先将“var week”放在一个新行上,我尝试了多种 /n 方法,但每次它要么破坏脚本,要么什么都不做。另外我需要做的另一件事是创建一个循环,它将显示每月的每一天(例如,周一 1、周二、周三 3 等,直到显示四月的所有日子),对于我的一生,我可以不知道如何做到这一点,所以任何人都可以帮助我提供一些关于如何将它们组合在一起的提示吗?是的,我已经搜索了很长时间关于如何创建空间的问题,但没有任何结果有帮助。
编辑:我更新了代码我终于想出了如何显示日期,但我不知道如何显示它们之后的数字,我也想出了如何换行,对于大量的文字感到抱歉。
<script>
var monthArray=["January","February","March","April","May","June","July","August","September","October","November","December"];
var weekDaysArray=["Sun","Mon","Tues","Wed","Thurs","Fri","Sat"];
//The comments below are for the current date but I was not sure if we were supposed to show that
//var todaysDate=new Date();
//document.write(todaysDate);
var currMon=monthArray[3];
document.write(currMon);
document.write("\n");
var d = new Date();
var currYr = d.getFullYear();
document.write(currYr +"<br>");
var week="Week 1 of April.";
document.write(week +"<br>");
for (var i=0;i<weekDaysArray.length;i++)
{
document.write(weekDaysArray[i] + "<br>");
}
</script>