Skip to content

Commit 75f6ae2

Browse files
a2937lasjorg
andauthored
fix(curriculum) : update head step 4 (freeCodeCamp#55882)
Co-authored-by: Lasse Jørgensen <[email protected]>
1 parent 9d7fa46 commit 75f6ae2

File tree

1 file changed

+30
-13
lines changed

1 file changed

+30
-13
lines changed

curriculum/challenges/english/14-responsive-web-design-22/learn-css-variables-by-building-a-city-skyline/5d822fd413a79914d39e98cc.md

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,20 @@ Within the `head`, nest a `meta` element with a `charset` of `UTF-8`, a `title`
1414
You should create a `meta` element within the `head` element.
1515

1616
```js
17-
assert.exists(document.querySelector('head > meta'));
17+
const headContentRegex = /(?<=<head\s*>)[\S|\s]*(?=<\/head\s*>)/;
18+
const headElementContent = code.match(headContentRegex);
19+
20+
const headElement = document.createElement("head");
21+
headElement.innerHTML = headElementContent;
22+
assert.isNotNull(headElement.querySelector('meta'));
1823
```
1924

2025
You should give the `meta` tag a `charset` of `UTF-8`.
2126

2227
```js
23-
assert.equal(document.querySelector('head > meta')?.getAttribute('charset')?.toLowerCase(), 'utf-8');
28+
const linkElement = document.querySelector('meta');
29+
const charset = linkElement?.getAttribute("charset").toLowerCase();
30+
assert.strictEqual(charset, 'utf-8');
2431
```
2532
2633
Your code should have a `title` element.
@@ -33,7 +40,12 @@ assert.exists(title);
3340
The `title` element should be within the `head` element.
3441
3542
```js
36-
assert.exists(document.querySelector('head > title'));
43+
const headContentRegex = /(?<=<head\s*>)[\S|\s]*(?=<\/head\s*>)/;
44+
const headElementContent = code.match(headContentRegex);
45+
46+
const headElement = document.createElement("head");
47+
headElement.innerHTML = headElementContent;
48+
assert.isNotNull(headElement.querySelector('title'));
3749
```
3850
3951
Your project should have a title of `City Skyline`.
@@ -53,41 +65,46 @@ assert.equal(title.text, 'City Skyline');
5365
Your code should have a `link` element.
5466
5567
```js
56-
assert.match(code, /<link/)
68+
assert.isNotNull(document.querySelector('link'));
5769
```
5870
5971
You should not change your existing `head` tags. Make sure you did not delete the closing tag.
6072
6173
```js
62-
const heads = document.querySelectorAll('head');
63-
assert.equal(heads?.length, 1);
74+
const headElements = document.querySelectorAll('head');
75+
assert.strictEqual(headElements?.length, 1);
6476
```
6577
6678
You should have one void `link` element.
6779
6880
```js
69-
assert(document.querySelectorAll('link').length === 1);
81+
assert.strictEqual(document.querySelectorAll('link')?.length, 1);
7082
```
7183
7284
Your `link` element should be within your `head` element.
7385
7486
```js
75-
assert.exists(document.querySelector('head > link'));
87+
const headContentRegex = /(?<=<head\s*>)[\S|\s]*(?=<\/head\s*>)/;
88+
const headElementContent = code.match(headContentRegex);
89+
90+
const headElement = document.createElement("head");
91+
headElement.innerHTML = headElementContent;
92+
assert.isNotNull(headElement.querySelector('link'));
7693
```
7794
7895
Your `link` element should have a `rel` attribute with the value `stylesheet`.
7996
8097
```js
81-
const link_element = document.querySelector('link');
82-
const rel = link_element.getAttribute("rel");
83-
assert.equal(rel, "stylesheet");
98+
const linkElement = document.querySelector('link');
99+
const rel = linkElement?.getAttribute("rel");
100+
assert.strictEqual(rel, "stylesheet");
84101
```
85102
86103
Your `link` element should have an `href` attribute with the value `styles.css`.
87104
88105
```js
89-
const link = document.querySelector('link');
90-
assert.equal(link.dataset.href, "styles.css");
106+
const linkElement = document.querySelector('link');
107+
assert.strictEqual(linkElement?.dataset.href, "styles.css");
91108
```
92109
93110
# --seed--

0 commit comments

Comments
 (0)