Skip to content

Commit 973143b

Browse files
a2937gikf
andauthored
feat(curriculum) : remove jQuery from bootstrap project (freeCodeCamp#55950)
Co-authored-by: Krzysztof G. <[email protected]>
1 parent c968c18 commit 973143b

31 files changed

+264
-266
lines changed

curriculum/challenges/english/03-front-end-development-libraries/bootstrap/add-elements-within-your-bootstrap-wells.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,27 @@ Nest three `button` elements within each of your `div` elements having the class
1717
Three `button` elements should be nested within each of your `div` elements with class `well`.
1818

1919
```js
20-
assert(
21-
$('div.well:eq(0)').children('button').length === 3 &&
22-
$('div.well:eq(1)').children('button').length === 3
23-
);
20+
const buttonOne = document.querySelectorAll('div.well')?.[0];
21+
const buttonOneChildren = buttonOne?.querySelectorAll(`:scope ${'button'}`);
22+
assert.lengthOf(buttonOneChildren,3);
23+
24+
const buttonTwo = document.querySelectorAll('div.well')?.[1]
25+
const buttonTwoChildren = buttonTwo?.querySelectorAll(`:scope ${'button'}`);
26+
assert.lengthOf(buttonTwoChildren,3);
2427
```
2528
2629
You should have a total of 6 `button` elements.
2730
2831
```js
29-
assert($('button') && $('button').length > 5);
32+
assert.lengthOf(document.querySelectorAll('button'), 6);
3033
```
3134
3235
All of your `button` elements should have closing tags.
3336
3437
```js
35-
assert(
36-
code.match(/<\/button>/g) &&
37-
code.match(/<button/g) &&
38-
code.match(/<\/button>/g).length === code.match(/<button/g).length
39-
);
38+
assert.match(code,/<\/button>/g);
39+
assert.match(code,/<button/g);
40+
assert.equal(code.match(/<\/button>/g).length,code.match(/<button/g).length);
4041
```
4142
4243
# --seed--

curriculum/challenges/english/03-front-end-development-libraries/bootstrap/add-font-awesome-icons-to-all-of-our-buttons.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,29 +24,29 @@ Use Font Awesome to add an `info-circle` icon to your info button and a `trash`
2424
You should add a `<i class="fas fa-info-circle"></i>` within your `info` button element.
2525

2626
```js
27-
assert(
28-
$('.btn-info > i').is('.fas.fa-info-circle') ||
29-
$('.btn-info > span').is('.fas.fa-info-circle')
27+
assert.isTrue(
28+
document.querySelector('.btn-info > i')?.classList?.value === 'fas fa-info-circle' ||
29+
document.querySelector('.btn-info > span')?.classList?.value === 'fas fa-info-circle'
3030
);
3131
```
3232
3333
You should add a `<i class="fas fa-trash"></i>` within your `delete` button element.
3434
3535
```js
36-
assert(
37-
$('.btn-danger > i').is('.fas.fa-trash') ||
38-
$('.btn-danger > span').is('.fas.fa-trash')
36+
assert.isTrue(
37+
document.querySelector('.btn-danger > i')?.classList?.value === 'fas fa-trash' ||
38+
document.querySelector('.btn-danger > span')?.classList?.value === 'fas fa-trash'
3939
);
4040
```
4141
4242
Each of your `i` elements should have a closing tag and `<i class="fas fa-thumbs-up"></i>` is in your `like` button element.
4343
4444
```js
45-
assert(
46-
code.match(/<\/i>|<\/span/g) &&
47-
code.match(/<\/i|<\/span>/g).length > 2 &&
48-
($('.btn-primary > i').is('.fas.fa-thumbs-up') ||
49-
$('.btn-primary > span').is('.fas.fa-thumbs-up'))
45+
assert.match(code,/<\/i>|<\/span/g);
46+
assert.lengthOf(code.match(/<\/i|<\/span>/g),4)
47+
assert.isTrue(
48+
document.querySelector('.btn-primary > i')?.classList?.value === 'fas fa-thumbs-up' ||
49+
document.querySelector('.btn-primary > span')?.classList?.value === 'fas fa-thumbs-up'
5050
);
5151
```
5252

curriculum/challenges/english/03-front-end-development-libraries/bootstrap/add-font-awesome-icons-to-our-buttons.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,33 +38,34 @@ Use Font Awesome to add a `thumbs-up` icon to your like button by giving it an `
3838
You should add an `i` element with the classes `fas` and `fa-thumbs-up`.
3939

4040
```js
41-
assert($('i').is('.fas.fa-thumbs-up') || $('span').is('.fas.fa-thumbs-up'));
41+
assert.isTrue(document.querySelector('i')?.classList?.value === 'fas fa-thumbs-up' || document.querySelector('span')?.classList?.value === 'fas fa-thumbs-up');
4242
```
4343
4444
Your `fa-thumbs-up` icon should be located within the Like button.
4545
4646
```js
47-
assert(
48-
($('i.fa-thumbs-up').parent().text().match(/Like/gi) &&
49-
$('.btn-primary > i').is('.fas.fa-thumbs-up')) ||
50-
($('span.fa-thumbs-up').parent().text().match(/Like/gi) &&
51-
$('.btn-primary > span').is('.fas.fa-thumbs-up'))
52-
);
47+
const iconTextContent = document.querySelector('i.fa-thumbs-up')?.parentNode?.textContent;
48+
const spanTextContent = document.querySelector('span.fa-thumbs-up')?.parentNode?.textContent;
49+
assert.isTrue(
50+
(iconTextContent?.match(/Like/gi) &&
51+
document.querySelector('.btn-primary > i') === document.querySelector('.fas.fa-thumbs-up')) ||
52+
(spanTextContent?.match(/Like/gi) &&
53+
document.querySelector('.btn-primary > span') === document.querySelector('.fas.fa-thumbs-up')));
5354
```
5455
5556
Your `i` element should be nested within your `button` element.
5657
5758
```js
58-
assert(
59-
$('button').children('i').length > 0 ||
60-
$('button').children('span').length > 0
61-
);
59+
const button = document.querySelector('button');
60+
const i = button?.querySelectorAll("i");
61+
const span = button?.querySelectorAll("span");
62+
assert(i.length > 0 ||span.length > 0);
6263
```
6364
6465
Your icon element should have a closing tag.
6566
6667
```js
67-
assert(code.match(/<\/i>|<\/span>/g));
68+
assert.match(code, /(<\/i>|<\/span>)\s*Like\s*<\/button>/g);
6869
```
6970
7071
# --seed--

curriculum/challenges/english/03-front-end-development-libraries/bootstrap/add-id-attributes-to-bootstrap-elements.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,17 @@ Give the well on the left the id of `left-well`. Give the well on the right the
2727
Your left `well` should have the id of `left-well`.
2828

2929
```js
30-
assert(
31-
$('.col-xs-6').children('#left-well') &&
32-
$('.col-xs-6').children('#left-well').length > 0
33-
);
30+
const column = document.querySelectorAll('.col-xs-6')[0];
31+
const leftWall = column?.querySelectorAll(`:scope ${'#left-well'}`);
32+
assert.lengthOf(leftWall,1)
3433
```
3534
3635
Your right `well` should have the id of `right-well`.
3736
3837
```js
39-
assert(
40-
$('.col-xs-6').children('#right-well') &&
41-
$('.col-xs-6').children('#right-well').length > 0
42-
);
38+
const column = document.querySelectorAll('.col-xs-6')[1];
39+
const rightWall = column?.querySelectorAll(`:scope ${'#right-well'}`);
40+
assert.lengthOf(rightWall,1)
4341
```
4442
4543
# --seed--

curriculum/challenges/english/03-front-end-development-libraries/bootstrap/apply-the-default-bootstrap-button-style.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ Apply both the `btn` and `btn-default` classes to each of your `button` elements
1717
You should apply the `btn` class to each of your `button` elements.
1818

1919
```js
20-
assert($('.btn').length > 5);
20+
assert.lengthOf(document.querySelectorAll('.btn'),6);
2121
```
2222

2323
You should apply the `btn-default` class to each of your `button` elements.
2424

2525
```js
26-
assert($('.btn-default').length > 5);
26+
assert.lengthOf(document.querySelectorAll('.btn-default'), 6);
2727
```
2828

2929
# --seed--

curriculum/challenges/english/03-front-end-development-libraries/bootstrap/call-out-optional-actions-with-btn-info.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,30 @@ Note that these buttons still need the `btn` and `btn-block` classes.
1919
You should create a new `button` element with the text `Info`.
2020

2121
```js
22-
assert(new RegExp('info', 'gi').test($('button').text()));
22+
const infoButton = document.querySelectorAll('button')?.[1];
23+
assert.match(infoButton.textContent,/info/gi);
2324
```
2425
2526
Both of your Bootstrap buttons should have the `btn` and `btn-block` classes.
2627
2728
```js
28-
assert($('button.btn-block.btn').length > 1);
29+
assert.lengthOf(document.querySelectorAll('button.btn-block.btn'),2);
2930
```
3031
3132
Your new button should have the class `btn-info`.
3233
3334
```js
34-
assert($('button').hasClass('btn-info'));
35+
const infoButton = [...document.querySelectorAll('button')].at(1);
36+
assert.isTrue(infoButton?.classList?.contains('btn-info'));
3537
```
3638
3739
All of your `button` elements should have closing tags.
3840
3941
```js
40-
assert(
41-
code.match(/<\/button>/g) &&
42-
code.match(/<button/g) &&
43-
code.match(/<\/button>/g).length === code.match(/<button/g).length
44-
);
42+
assert.match(code,/<\/button>/g);
43+
assert.match(code,/<button/g);
44+
45+
assert.equal(code.match(/<\/button>/g)?.length,code.match(/<button/g)?.length);
4546
```
4647
4748
# --seed--

curriculum/challenges/english/03-front-end-development-libraries/bootstrap/center-text-with-bootstrap.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ Remember that you can add several classes to the same element by separating each
2121
Your `h2` element should be centered by applying the class `text-center`
2222

2323
```js
24-
assert($('h2').hasClass('text-center'));
24+
assert.isTrue(document.querySelector('h2')?.classList?.contains('text-center'));
2525
```
2626
2727
Your `h2` element should still have the class `red-text`
2828
2929
```js
30-
assert($('h2').hasClass('red-text'));
30+
assert.isTrue(document.querySelector('h2')?.classList?.contains('red-text'));
3131
```
3232
3333
# --seed--

curriculum/challenges/english/03-front-end-development-libraries/bootstrap/create-a-block-element-bootstrap-button.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,22 @@ Add Bootstrap's `btn-block` class to your Bootstrap button.
3737
Your button should still have the `btn` and `btn-default` classes.
3838

3939
```js
40-
assert($('button').hasClass('btn') && $('button').hasClass('btn-default'));
40+
assert.isTrue(document.querySelector('button')?.classList?.contains('btn'));
41+
assert.isTrue(document.querySelector('button')?.classList?.contains('btn-default'));
4142
```
4243
4344
Your button should have the class `btn-block`.
4445
4546
```js
46-
assert($('button').hasClass('btn-block'));
47+
assert.isTrue(document.querySelector('button')?.classList?.contains('btn-block'));
4748
```
4849
4950
All of your `button` elements should have closing tags.
5051
5152
```js
52-
assert(
53-
code.match(/<\/button>/g) &&
54-
code.match(/<button/g) &&
55-
code.match(/<\/button>/g).length === code.match(/<button/g).length
56-
);
53+
assert.match(code,/<\/button>/g);
54+
assert.match(code,/<button/g);
55+
assert.equal(code.match(/<\/button>/g).length, code.match(/<button/g).length);
5756
```
5857
5958
# --seed--

curriculum/challenges/english/03-front-end-development-libraries/bootstrap/create-a-bootstrap-button.md

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,23 @@ Create a new `button` element below your large kitten photo. Give it the `btn` a
1717
You should create a new `button` element with the text `Like`.
1818

1919
```js
20-
assert(
21-
new RegExp('like', 'gi').test($('button').text()) &&
22-
$('img.img-responsive + button.btn').length > 0
23-
);
20+
assert.match(document.querySelector('button')?.textContent, /like/gi);
21+
assert.lengthOf(document.querySelectorAll('img.img-responsive + button.btn'),1)
2422
```
2523
2624
Your new button should have two classes: `btn` and `btn-default`.
2725
2826
```js
29-
assert($('button').hasClass('btn') && $('button').hasClass('btn-default'));
27+
assert.isTrue(document.querySelector('button')?.classList?.contains('btn') )
28+
assert.isTrue(document.querySelector('button')?.classList?.contains('btn-default'));
3029
```
3130
3231
All of your `button` elements should have closing tags.
3332
3433
```js
35-
assert(
36-
code.match(/<\/button>/g) &&
37-
code.match(/<button/g) &&
38-
code.match(/<\/button>/g).length === code.match(/<button/g).length
39-
);
34+
assert.match(code,/<\/button>/g);
35+
assert.match(code,/<button/g);
36+
assert.equal(code.match(/<\/button>/g).length ,code.match(/<button/g).length);
4037
```
4138
4239
# --seed--

curriculum/challenges/english/03-front-end-development-libraries/bootstrap/create-a-bootstrap-headline.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,35 +21,33 @@ Color your `h3` element with the `text-primary` Bootstrap class, and center it w
2121
You should add an `h3` element to your page.
2222

2323
```js
24-
assert($('h3') && $('h3').length > 0);
24+
assert.lengthOf(document.querySelectorAll('h3'),1);
2525
```
2626

2727
Your `h3` element should have a closing tag.
2828

2929
```js
30-
assert(
31-
code.match(/<\/h3>/g) &&
32-
code.match(/<h3/g) &&
33-
code.match(/<\/h3>/g).length === code.match(/<h3/g).length
34-
);
30+
assert.match(code,/<\/h3>/g);
31+
assert.match(code,/<h3/g);
32+
assert.equal( code.match(/<\/h3>/g).length , code.match(/<h3/g).length);
3533
```
3634

3735
Your `h3` element should be colored by applying the class `text-primary`
3836

3937
```js
40-
assert($('h3').hasClass('text-primary'));
38+
assert.isTrue(document.querySelector('h3')?.classList?.contains('text-primary'));
4139
```
4240
4341
Your `h3` element should be centered by applying the class `text-center`
4442
4543
```js
46-
assert($('h3').hasClass('text-center'));
44+
assert.isTrue(document.querySelector('h3')?.classList?.contains('text-center'));
4745
```
4846
4947
Your `h3` element should have the text `jQuery Playground`.
5048
5149
```js
52-
assert.isTrue(/jquery(\s)+playground/gi.test($('h3').text()));
50+
assert.match(document.querySelector('h3')?.textContent, /jquery(\s)+playground/gi);
5351
```
5452
5553
# --seed--

0 commit comments

Comments
 (0)