feat(curriculum): javascript date-quiz (#56754)

This commit is contained in:
Othniel Ojochonu Abalaka
2024-10-24 01:37:30 +01:00
committed by GitHub
parent 32e05b6c51
commit 692c1dfc14
@@ -17,439 +17,456 @@ To pass the quiz, you must correctly answer at least 17 of the 20 of the questio
#### --text--
Placeholder question
What is the JavaScript `Date` object used for?
#### --distractors--
Placeholder distractor 1
Work with just dates only.
---
Placeholder distractor 2
Work with just time only.
---
Placeholder distractor 3
None of the others.
#### --answer--
Placeholder answer
Work with both dates and time.
### --question--
#### --text--
Placeholder question
Which code creates a new `Date` object instance?
#### --distractors--
Placeholder distractor 1
`Date.new()`
---
Placeholder distractor 2
`Date.fetch()`
---
Placeholder distractor 3
`new.Date()`
#### --answer--
Placeholder answer
`new Date()`
### --question--
#### --text--
Placeholder question
How does `Date.now()` work?
#### --distractors--
Placeholder distractor 1
It returns the current time in nanoseconds since July 4, 1776.
---
Placeholder distractor 2
It returns the previous time in milliseconds since January 1, 1974.
---
Placeholder distractor 3
It returns the current date in minutes since January 1, 1970.
#### --answer--
Placeholder answer
It returns the current time in milliseconds since January 1, 1970.
### --question--
#### --text--
Placeholder question
Which method returns the current year?
#### --distractors--
Placeholder distractor 1
`getNewYear()`
---
Placeholder distractor 2
`getLastYear()`
---
Placeholder distractor 3
`getLeapYear()`
#### --answer--
Placeholder answer
`getFullYear()`
### --question--
#### --text--
Placeholder question
Which method returns the current month, as a zero-indexed integer?
#### --distractors--
Placeholder distractor 1
`getCalender()`
---
Placeholder distractor 2
`fetchMonth()`
---
Placeholder distractor 3
`get.Month()`
#### --answer--
Placeholder answer
`getMonth()`
### --question--
#### --text--
Placeholder question
Which method formats a date as a string?
#### --distractors--
Placeholder distractor 1
`getMonth()`
---
Placeholder distractor 2
`formatDate()`
---
Placeholder distractor 3
`toStingy()`
#### --answer--
Placeholder answer
`toString()`
### --question--
#### --text--
Placeholder question
What would the result of `console.log(new Date().getFullYear());` be, if it is June 12th 2022?
#### --distractors--
Placeholder distractor 1
`"June 12th 2022"`
---
Placeholder distractor 2
`"2023"`
---
Placeholder distractor 3
`"06/12/2022"`
#### --answer--
Placeholder answer
`"2022"`
### --question--
#### --text--
Placeholder question
What will be the output of the following code?
```js
console.log(new Date("2023-06-18T12:00:00Z").toUTCString());
```
#### --distractors--
Placeholder distractor 1
`"Mon, 19 Jun 2023 12:00:00 GMT"`
---
Placeholder distractor 2
`"Sun, 18 Jun 2023 12:00:00 GMT+1"`
---
Placeholder distractor 3
`"Sun, 18 Jun 2023 13:00:00 GMT"`
#### --answer--
Placeholder answer
`"Sun, 18 Jun 2023 12:00:00 GMT"`
### --question--
#### --text--
Placeholder question
If the time in your locale is formatted as `HH:MM:SS AM/PM`, which line of code would correctly display the current time?
#### --distractors--
Placeholder distractor 1
`console.log(new Date().toLocaleDateString());`
---
Placeholder distractor 2
`console.log(new Date().toString());`
---
Placeholder distractor 3
`console.log(new Date().toCityDateString());`
#### --answer--
Placeholder answer
`console.log(new Date().toLocaleTimeString());`
### --question--
#### --text--
Placeholder question
How does the `toISOString()` method format a date?
#### --distractors--
Placeholder distractor 1
A USA-863 string format.
---
Placeholder distractor 2
An MP3 string format.
---
Placeholder distractor 3
A UTC string format.
#### --answer--
Placeholder answer
An ISO-8601 string format.
### --question--
#### --text--
Placeholder question
What should an ISO-8601 date format look like?
#### --distractors--
Placeholder distractor 1
DD-MM-YYYY
---
Placeholder distractor 2
DD-MM-YYTHH
---
Placeholder distractor 3
YYYY-MM-DDTHH:mm:ssZ
#### --answer--
Placeholder answer
YYYY-MM-DDTHH:mm:ss.sssZ
### --question--
#### --text--
Placeholder question
What is the output of `console.log(new Date(2003, 6, 27).getMonth());`?
#### --distractors--
Placeholder distractor 1
`"27/6/2003"`
---
Placeholder distractor 2
`27`
---
Placeholder distractor 3
`2003`
#### --answer--
Placeholder answer
`6`
### --question--
#### --text--
Placeholder question
How would you format a date to a locale-specific string or a more readable format?
#### --distractors--
Placeholder distractor 1
`.toLocaleDate()`
---
Placeholder distractor 2
`.toLocaleString()`
---
Placeholder distractor 3
`.toLocaleTimetring()`
#### --answer--
Placeholder answer
`.toLocaleDateString()`
### --question--
#### --text--
Placeholder question
Which option will correctly create a string representing January 1, 2025?
```js
const d = ?;
console.log(d.toISOString().split("T")[0]);
```
#### --distractors--
Placeholder distractor 1
`const d = new Date("2021-02-01");`
---
Placeholder distractor 2
`const d = new Date("2003-06-06");`
---
Placeholder distractor 3
`const d = new Date("2001-04-08");`
#### --answer--
Placeholder answer
`const d = new Date("2025-01-01");`
### --question--
#### --text--
Placeholder question
What does `new Date().getDay()` return?
#### --distractors--
Placeholder distractor 1
It returns the current day of the week as a string. Starting with Friday as `0`.
---
Placeholder distractor 2
It returns the current day of the year as a number. Starting with Monday as `0`.
---
Placeholder distractor 3
It returns the current day of the month as a decimal. Starting with Sunday as `1`.
#### --answer--
Placeholder answer
It returns the current day of the week as a number. Starting with Sunday as `0`.
### --question--
#### --text--
Placeholder question
What is the output of `console.log(new Date(2003, 6, 27).getFullYear());`?
#### --distractors--
Placeholder distractor 1
`"27/6/2003"`
---
Placeholder distractor 2
`27`
---
Placeholder distractor 3
`6`
#### --answer--
Placeholder answer
`2003`
### --question--
#### --text--
Placeholder question
The `toUTCString()` method formats a date as?
#### --distractors--
Placeholder distractor 1
A door dash string format.
---
Placeholder distractor 2
An MP3 string format.
---
Placeholder distractor 3
An ISO-8601 string format.
#### --answer--
Placeholder answer
A UTC string format.
### --question--
#### --text--
Placeholder question
If we are in the month of October, what will `console.log(new Date().getMonth());` output?
#### --distractors--
Placeholder distractor 1
`1`
---
Placeholder distractor 2
`3`
---
Placeholder distractor 3
`10`
#### --answer--
Placeholder answer
`9`
### --question--
#### --text--
Placeholder question
Which option will output `"2021"` for the following object?
```js
const d = new Date("2021-12-25");
```
#### --distractors--
Placeholder distractor 1
`console.log(d.getTime())`
---
Placeholder distractor 2
`console.log(d.toUTCString())`
---
Placeholder distractor 3
`console.log(d.getDate())`
#### --answer--
Placeholder answer
`console.log(d.getFullYear())`
### --question--
#### --text--
Placeholder question
Which option will output `"2021-12-25T00:00:00.000Z"` for the following object?
```js
const d = new Date("2021-12-25");
```
#### --distractors--
Placeholder distractor 1
`console.log(d.getFullYear())`
---
Placeholder distractor 2
`console.log(d.toUTCString())`
---
Placeholder distractor 3
`console.log(d.getTime())`
#### --answer--
Placeholder answer
`console.log(d.toISOString())`