Skip to content

Commit 6fa282c

Browse files
a2937naomi-lgbt
andauthored
chore(curriculum): update asserts in legacy basic algorithm scripting (freeCodeCamp#57784)
Co-authored-by: Naomi <[email protected]>
1 parent 52dd67a commit 6fa282c

15 files changed

+172
-146
lines changed

curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-algorithm-scripting/boo-who.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,61 +17,61 @@ Boolean primitives are `true` and `false`.
1717
`booWho(true)` should return `true`.
1818

1919
```js
20-
assert.strictEqual(booWho(true), true);
20+
assert.isTrue(booWho(true));
2121
```
2222

2323
`booWho(false)` should return `true`.
2424

2525
```js
26-
assert.strictEqual(booWho(false), true);
26+
assert.isTrue(booWho(false));
2727
```
2828

2929
`booWho([1, 2, 3])` should return `false`.
3030

3131
```js
32-
assert.strictEqual(booWho([1, 2, 3]), false);
32+
assert.isFalse(booWho([1, 2, 3]));
3333
```
3434

3535
`booWho([].slice)` should return `false`.
3636

3737
```js
38-
assert.strictEqual(booWho([].slice), false);
38+
assert.isFalse(booWho([].slice));
3939
```
4040

4141
`booWho({ "a": 1 })` should return `false`.
4242

4343
```js
44-
assert.strictEqual(booWho({ a: 1 }), false);
44+
assert.isFalse(booWho({ a: 1 }));
4545
```
4646

4747
`booWho(1)` should return `false`.
4848

4949
```js
50-
assert.strictEqual(booWho(1), false);
50+
assert.isFalse(booWho(1));
5151
```
5252

5353
`booWho(NaN)` should return `false`.
5454

5555
```js
56-
assert.strictEqual(booWho(NaN), false);
56+
assert.isFalse(booWho(NaN));
5757
```
5858

5959
`booWho("a")` should return `false`.
6060

6161
```js
62-
assert.strictEqual(booWho('a'), false);
62+
assert.isFalse(booWho('a'));
6363
```
6464

6565
`booWho("true")` should return `false`.
6666

6767
```js
68-
assert.strictEqual(booWho('true'), false);
68+
assert.isFalse(booWho('true'));
6969
```
7070

7171
`booWho("false")` should return `false`.
7272

7373
```js
74-
assert.strictEqual(booWho('false'), false);
74+
assert.isFalse(booWho('false'));
7575
```
7676

7777
# --seed--
@@ -90,7 +90,7 @@ booWho(null);
9090

9191
```js
9292
function booWho(bool) {
93-
return typeof bool === "boolean";
93+
return typeof bool === 'boolean';
9494
}
9595

9696
booWho(null);

curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-algorithm-scripting/chunky-monkey.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function chunkArrayInGroups(arr, size) {
9090
return arr;
9191
}
9292

93-
chunkArrayInGroups(["a", "b", "c", "d"], 2);
93+
chunkArrayInGroups(['a', 'b', 'c', 'd'], 2);
9494
```
9595

9696
# --solutions--
@@ -106,5 +106,5 @@ function chunkArrayInGroups(arr, size) {
106106
return out;
107107
}
108108

109-
chunkArrayInGroups(["a", "b", "c", "d"], 2);
109+
chunkArrayInGroups(['a', 'b', 'c', 'd'], 2);
110110
```

curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-algorithm-scripting/confirm-the-ending.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,84 +10,85 @@ dashedName: confirm-the-ending
1010

1111
Check if a string (first argument, `str`) ends with the given target string (second argument, `target`).
1212

13-
This challenge *can* be solved with the `.endsWith()` method, which was introduced in ES2015. But for the purpose of this challenge, we would like you to use one of the JavaScript substring methods instead.
13+
This challenge _can_ be solved with the `.endsWith()` method, which was introduced in ES2015. But for the purpose of this challenge, we would like you to use one of the JavaScript substring methods instead.
1414

1515
# --hints--
1616

1717
`confirmEnding("Bastian", "n")` should return `true`.
1818

1919
```js
20-
assert(confirmEnding('Bastian', 'n') === true);
20+
assert.isTrue(confirmEnding('Bastian', 'n'));
2121
```
2222

2323
`confirmEnding("Congratulation", "on")` should return `true`.
2424

2525
```js
26-
assert(confirmEnding('Congratulation', 'on') === true);
26+
assert.isTrue(confirmEnding('Congratulation', 'on'));
2727
```
2828

2929
`confirmEnding("Connor", "n")` should return `false`.
3030

3131
```js
32-
assert(confirmEnding('Connor', 'n') === false);
32+
assert.isFalse(confirmEnding('Connor', 'n'));
3333
```
3434

3535
`confirmEnding("Walking on water and developing software from a specification are easy if both are frozen", "specification")` should return `false`.
3636

3737
```js
38-
assert(
38+
assert.isFalse(
3939
confirmEnding(
4040
'Walking on water and developing software from a specification are easy if both are frozen',
4141
'specification'
42-
) === false
42+
)
4343
);
4444
```
4545

4646
`confirmEnding("He has to give me a new name", "name")` should return `true`.
4747

4848
```js
49-
assert(confirmEnding('He has to give me a new name', 'name') === true);
49+
assert.isTrue(confirmEnding('He has to give me a new name', 'name'));
5050
```
5151

5252
`confirmEnding("Open sesame", "same")` should return `true`.
5353

5454
```js
55-
assert(confirmEnding('Open sesame', 'same') === true);
55+
assert.isTrue(confirmEnding('Open sesame', 'same'));
5656
```
5757

5858
`confirmEnding("Open sesame", "sage")` should return `false`.
5959

6060
```js
61-
assert(confirmEnding('Open sesame', 'sage') === false);
61+
assert.isFalse(confirmEnding('Open sesame', 'sage'));
6262
```
6363

6464
`confirmEnding("Open sesame", "game")` should return `false`.
6565

6666
```js
67-
assert(confirmEnding('Open sesame', 'game') === false);
67+
assert.isFalse(confirmEnding('Open sesame', 'game'));
6868
```
6969

7070
`confirmEnding("If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing", "mountain")` should return `false`.
7171

7272
```js
73-
assert(
73+
assert.isFalse(
7474
confirmEnding(
7575
'If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing',
7676
'mountain'
77-
) === false
77+
)
7878
);
7979
```
8080

8181
`confirmEnding("Abstraction", "action")` should return `true`.
8282

8383
```js
84-
assert(confirmEnding('Abstraction', 'action') === true);
84+
assert.isTrue(confirmEnding('Abstraction', 'action'));
8585
```
8686

8787
Your code should not use the built-in method `.endsWith()` to solve the challenge.
8888

8989
```js
90-
assert(!/\.endsWith\(.*?\)\s*?;?/.test(__helpers.removeJSComments(code)) && !/\['endsWith'\]/.test(__helpers.removeJSComments(code)));
90+
assert.notMatch(__helpers.removeJSComments(code), /\.endsWith\(.*?\)\s*?;?/);
91+
assert.notMatch(__helpers.removeJSComments(code), /\['endsWith'\]/);
9192
```
9293

9394
# --seed--
@@ -99,7 +100,7 @@ function confirmEnding(str, target) {
99100
return str;
100101
}
101102

102-
confirmEnding("Bastian", "n");
103+
confirmEnding('Bastian', 'n');
103104
```
104105

105106
# --solutions--
@@ -109,5 +110,5 @@ function confirmEnding(str, target) {
109110
return str.substring(str.length - target.length) === target;
110111
}
111112

112-
confirmEnding("Bastian", "n");
113+
confirmEnding('Bastian', 'n');
113114
```

curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-algorithm-scripting/convert-celsius-to-fahrenheit.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,37 +17,37 @@ You are given a variable `celsius` representing a temperature in Celsius. Use th
1717
`convertCtoF(0)` should return a number
1818

1919
```js
20-
assert(typeof convertCtoF(0) === 'number');
20+
assert.isNumber(convertCtoF(0));
2121
```
2222

2323
`convertCtoF(-30)` should return a value of `-22`
2424

2525
```js
26-
assert(convertCtoF(-30) === -22);
26+
assert.strictEqual(convertCtoF(-30), -22);
2727
```
2828

2929
`convertCtoF(-10)` should return a value of `14`
3030

3131
```js
32-
assert(convertCtoF(-10) === 14);
32+
assert.strictEqual(convertCtoF(-10), 14);
3333
```
3434

3535
`convertCtoF(0)` should return a value of `32`
3636

3737
```js
38-
assert(convertCtoF(0) === 32);
38+
assert.strictEqual(convertCtoF(0), 32);
3939
```
4040

4141
`convertCtoF(20)` should return a value of `68`
4242

4343
```js
44-
assert(convertCtoF(20) === 68);
44+
assert.strictEqual(convertCtoF(20), 68);
4545
```
4646

4747
`convertCtoF(30)` should return a value of `86`
4848

4949
```js
50-
assert(convertCtoF(30) === 86);
50+
assert.strictEqual(convertCtoF(30), 86);
5151
```
5252

5353
# --seed--
@@ -67,7 +67,7 @@ convertCtoF(30);
6767

6868
```js
6969
function convertCtoF(celsius) {
70-
let fahrenheit = celsius * 9/5 + 32;
70+
let fahrenheit = celsius * (9 / 5) + 32;
7171
return fahrenheit;
7272
}
7373

curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-algorithm-scripting/factorialize-a-number.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,31 +23,31 @@ Only integers greater than or equal to zero will be supplied to the function.
2323
`factorialize(5)` should return a number.
2424

2525
```js
26-
assert(typeof factorialize(5) === 'number');
26+
assert.isNumber(factorialize(5));
2727
```
2828

2929
`factorialize(5)` should return `120`.
3030

3131
```js
32-
assert(factorialize(5) === 120);
32+
assert.strictEqual(factorialize(5), 120);
3333
```
3434

3535
`factorialize(10)` should return `3628800`.
3636

3737
```js
38-
assert(factorialize(10) === 3628800);
38+
assert.strictEqual(factorialize(10), 3628800);
3939
```
4040

4141
`factorialize(20)` should return `2432902008176640000`.
4242

4343
```js
44-
assert(factorialize(20) === 2432902008176640000);
44+
assert.strictEqual(factorialize(20), 2432902008176640000);
4545
```
4646

4747
`factorialize(0)` should return `1`.
4848

4949
```js
50-
assert(factorialize(0) === 1);
50+
assert.strictEqual(factorialize(0), 1);
5151
```
5252

5353
# --seed--

curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-algorithm-scripting/falsy-bouncer.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ You should not mutate `arr`.
4545
```js
4646
const arr = ['a', false, 0, 'Naomi'];
4747
bouncer(arr);
48-
assert.deepEqual(arr, ['a', false, 0, 'Naomi'])
48+
assert.deepEqual(arr, ['a', false, 0, 'Naomi']);
4949
```
5050

5151
# --seed--
@@ -57,7 +57,7 @@ function bouncer(arr) {
5757
return arr;
5858
}
5959

60-
bouncer([7, "ate", "", false, 9]);
60+
bouncer([7, 'ate', '', false, 9]);
6161
```
6262

6363
# --solutions--
@@ -67,5 +67,5 @@ function bouncer(arr) {
6767
return arr.filter(e => e);
6868
}
6969

70-
bouncer([7, "ate", "", false, 9]);
70+
bouncer([7, 'ate', '', false, 9]);
7171
```

0 commit comments

Comments
 (0)