Skip to content

Commit 26b8ddf

Browse files
refactor(curriculum): remove use of after-user-code (freeCodeCamp#60292)
1 parent 4424194 commit 26b8ddf

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

curriculum/challenges/english/01-responsive-web-design/applied-accessibility/standardize-times-with-the-html5-datetime-attribute.md

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,45 +21,50 @@ Here's an example:
2121

2222
Camper Cat's Mortal Kombat survey results are in! Wrap a `time` tag around the text `Thursday, September 15<sup>th</sup>` and add a `datetime` attribute to it set to `2016-09-15`.
2323

24+
# --before-all--
25+
26+
```js
27+
const getTimeElement = () => {
28+
const pElement = [...document.querySelectorAll("article > p")]
29+
.filter(x => x?.textContent?.includes("Thank you to everyone for responding to Master Camper Cat's survey."));
30+
31+
return pElement[0] ? pElement[0].querySelector("time") : null;
32+
};
33+
34+
const getDatetimeAttr = () => {
35+
const timeElement = getTimeElement();
36+
return timeElement?.getAttribute("datetime");
37+
};
38+
```
39+
2440
# --hints--
2541
2642
Your code should have a `p` element which includes the text `Thank you to everyone for responding to Master Camper Cat's survey.` and include a `time` element.
2743
2844
```js
29-
assert.exists(timeElement);
45+
assert.exists(getTimeElement());
3046
```
3147
3248
Your added `time` tags should wrap around the text `Thursday, September 15<sup>th</sup>`.
3349
3450
```js
35-
assert.strictEqual(timeElement?.innerHTML?.trim(), 'Thursday, September 15<sup>th</sup>');
51+
assert.strictEqual(getTimeElement()?.innerHTML?.trim(), 'Thursday, September 15<sup>th</sup>');
3652
```
3753
3854
Your added `time` tag should have a `datetime` attribute that is not empty.
3955
4056
```js
41-
assert(datetimeAttr?.length != 0);
57+
assert(getDatetimeAttr()?.length != 0);
4258
```
4359
4460
Your added `datetime` attribute should be set to a value of `2016-09-15`.
4561
4662
```js
47-
assert.equal(datetimeAttr , '2016-09-15');
63+
assert.equal(getDatetimeAttr() , '2016-09-15');
4864
```
4965
5066
# --seed--
5167
52-
## --after-user-code--
53-
54-
```html
55-
<script>
56-
const pElement = [...document.querySelectorAll("article > p")]
57-
.filter(x => x?.textContent?.includes("Thank you to everyone for responding to Master Camper Cat's survey."));
58-
const timeElement = pElement[0] ? pElement[0].querySelector("time") : null;
59-
const datetimeAttr = timeElement?.getAttribute("datetime");
60-
</script>
61-
```
62-
6368
## --seed-contents--
6469
6570
```html

0 commit comments

Comments
 (0)