mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
refactor(curriculum): remove use of after-user-code (#60292)
This commit is contained in:
committed by
GitHub
parent
4424194c7a
commit
26b8ddf583
+20
-15
@@ -21,45 +21,50 @@ Here's an example:
|
||||
|
||||
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`.
|
||||
|
||||
# --before-all--
|
||||
|
||||
```js
|
||||
const getTimeElement = () => {
|
||||
const pElement = [...document.querySelectorAll("article > p")]
|
||||
.filter(x => x?.textContent?.includes("Thank you to everyone for responding to Master Camper Cat's survey."));
|
||||
|
||||
return pElement[0] ? pElement[0].querySelector("time") : null;
|
||||
};
|
||||
|
||||
const getDatetimeAttr = () => {
|
||||
const timeElement = getTimeElement();
|
||||
return timeElement?.getAttribute("datetime");
|
||||
};
|
||||
```
|
||||
|
||||
# --hints--
|
||||
|
||||
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.
|
||||
|
||||
```js
|
||||
assert.exists(timeElement);
|
||||
assert.exists(getTimeElement());
|
||||
```
|
||||
|
||||
Your added `time` tags should wrap around the text `Thursday, September 15<sup>th</sup>`.
|
||||
|
||||
```js
|
||||
assert.strictEqual(timeElement?.innerHTML?.trim(), 'Thursday, September 15<sup>th</sup>');
|
||||
assert.strictEqual(getTimeElement()?.innerHTML?.trim(), 'Thursday, September 15<sup>th</sup>');
|
||||
```
|
||||
|
||||
Your added `time` tag should have a `datetime` attribute that is not empty.
|
||||
|
||||
```js
|
||||
assert(datetimeAttr?.length != 0);
|
||||
assert(getDatetimeAttr()?.length != 0);
|
||||
```
|
||||
|
||||
Your added `datetime` attribute should be set to a value of `2016-09-15`.
|
||||
|
||||
```js
|
||||
assert.equal(datetimeAttr , '2016-09-15');
|
||||
assert.equal(getDatetimeAttr() , '2016-09-15');
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --after-user-code--
|
||||
|
||||
```html
|
||||
<script>
|
||||
const pElement = [...document.querySelectorAll("article > p")]
|
||||
.filter(x => x?.textContent?.includes("Thank you to everyone for responding to Master Camper Cat's survey."));
|
||||
const timeElement = pElement[0] ? pElement[0].querySelector("time") : null;
|
||||
const datetimeAttr = timeElement?.getAttribute("datetime");
|
||||
</script>
|
||||
```
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```html
|
||||
|
||||
Reference in New Issue
Block a user