Microsoft
98-382 · Question #23
You are creating a calendar application. You need to ensure that the code works correctly for all months of the year. How should you complete the code? To answer, select the appropriate options in…
The problem requires completing a JavaScript code snippet by selecting appropriate options from dropdowns. Based on the explanation on page 5, the following code represents the correct completion: ``javascript var daysInMonth; var month; month = new Date().getMonth(); switch…
Performing Operations
Question
You are creating a calendar application. You need to ensure that the code works correctly for all months of the year. How should you complete the code? To answer, select the appropriate options in the answer area.
Explanation
The problem requires completing a JavaScript code snippet by selecting appropriate options from dropdowns. Based on the explanation on page 5, the following code represents the correct completion:
var daysInMonth;
var month;
month = new Date().getMonth();
switch (month){ // This 'switch (month)' was a selection for the first blank.
// Note: Lines like 'case (month){' and 'break {' shown in the question's 'Answer Area'
// are not valid JavaScript and are implicitly corrected/omitted in the solution structure.
case 1: // February
daysInMonth = 28; // for February, ignore leap years
case 3: break;
case 5:
continue; // This 'continue;' was a selection for the second blank.
case 8: while (month); // This line is given as part of the existing code.
case 10: // November
daysInMonth = 30;
break; // This 'break;' was a selection for the third blank.
}
Topics
#Date object#getMonth#calendar#months
Community Discussion
No community discussion yet for this question.