Skip to content

Commit 625138f

Browse files
naomi-lgbtlasjorg
andauthored
feat: address hardcoding (freeCodeCamp#55665)
Co-authored-by: Lasse Jørgensen <[email protected]>
1 parent 39cd45a commit 625138f

File tree

1 file changed

+26
-3
lines changed
  • curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator

1 file changed

+26
-3
lines changed

curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/66643c93e05093c728abdbe9.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,19 @@ Before moving on, take a moment to review how functions work.
1111

1212
Declare a function named `addTwoNumbers`. This function should take two arguments and return the sum of those two arguments.
1313

14-
Then declare a `sum` variable and assign it the value of calling your `addTwoNumbers` function with `5` and `10` as the arguments. Log the `sum` variable to the console.
14+
Your function should not use hard-coded values. An example of a hard-coded function might be:
1515

16+
```js
17+
function sayName(firstName, lastName) {
18+
return "John Doe";
19+
}
20+
21+
sayName("Camper", "Cat");
22+
```
23+
24+
This function would return `"John Doe"` regardless of the arguments passed to the parameters `firstName`, and `lastName`, so `"John Doe"` is considered a hard-coded value.
25+
26+
Declare a `sum` variable and assign it the value of calling your `addTwoNumbers` function with `5` and `10` as the arguments. Log the `sum` variable to the console.
1627

1728
# --hints--
1829

@@ -25,7 +36,13 @@ assert.isFunction(addTwoNumbers);
2536
Your function should return the sum of the two numbers.
2637

2738
```js
28-
assert.strictEqual(addTwoNumbers(2,3), 5);
39+
assert.strictEqual(addTwoNumbers(5,10), 15);
40+
```
41+
42+
Your function should not return a hard-coded value. That is, it should work with any two number arguments.
43+
44+
```js
45+
assert.strictEqual(addTwoNumbers(3, 5), 8);
2946
```
3047

3148
You should declare a `sum` variable.
@@ -34,12 +51,18 @@ You should declare a `sum` variable.
3451
assert.isDefined(sum);
3552
```
3653

37-
You should assign `sum` the value from calling the `addTwoNumbers` function with `5` and `10` for the arguments.
54+
Your `sum` variable should have the value `15`.
3855

3956
```js
4057
assert.strictEqual(sum, 15);
4158
```
4259

60+
You should assign `sum` the value from calling the `addTwoNumbers` function with `5` and `10` for the arguments.
61+
62+
```js
63+
assert.match(code, /sum\s*=\s*addTwoNumbers\s*\(/);
64+
```
65+
4366
You should log your `sum` variable.
4467

4568
```js

0 commit comments

Comments
 (0)