mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-08-31 01:14:08 +08:00
fix(curriculum): fix wording issues and simplify log checks in sentence maker lab (#69209)
This commit is contained in:
+17
-14
@@ -7,7 +7,7 @@ dashedName: build-a-sentence-maker
|
||||
|
||||
# --description--
|
||||
|
||||
In this lab, you will create two different stories using a sentence template. You will use variables to store different parts of the story and then output the stories to the console.
|
||||
In this lab, you will create two different stories using a sentence template. You will use variables to store different parts of the story and then log the stories to the console.
|
||||
|
||||
**Objective:** Fulfill the user stories below and get all the tests to pass to complete the lab.
|
||||
|
||||
@@ -26,19 +26,26 @@ In this lab, you will create two different stories using a sentence template. Yo
|
||||
|
||||
1. You should declare a `firstStory` variable.
|
||||
|
||||
1. You should use the following story template to create the first story and assign it to the `firstStory` variable: `"Once upon a time, there was a(n) [adjective] [noun] who loved to eat [noun2]. The [noun] lived in a [place] and had [adjective2] nostrils that blew fire when it was [verb]."`;
|
||||
1. You should use the following story template to create the first story and assign it to the `firstStory` variable: `"Once upon a time, there was a(n) [adjective] [noun] who loved to eat [noun2]. The [noun] lived in a [place] and had [adjective2] nostrils that blew fire when it was [verb]."`
|
||||
|
||||
1. You should output your first story to the console using the message `"First story: [firstStory]"`.
|
||||
1. You should log your first story to the console using the message `"First story: [firstStory]"`.
|
||||
|
||||
1. You should assign new values to your `adjective`, `noun`, `verb`, `place`, `adjective2`, and `noun2` variables.
|
||||
|
||||
1. You should declare a `secondStory` variable.
|
||||
|
||||
1. Create another story using the same template and assign it to the `secondStory` variable.
|
||||
1. You should create another story using the same template and assign it to the `secondStory` variable.
|
||||
|
||||
1. You should output your second story to the console using the message `"Second story: [secondStory]"`.
|
||||
1. You should log your second story to the console using the message `"Second story: [secondStory]"`.
|
||||
|
||||
|
||||
# --before-each--
|
||||
|
||||
```js
|
||||
const spy = __helpers.spyOn(console, 'log');
|
||||
const getLogs = () => spy.calls.map(call => call.join(' '));
|
||||
```
|
||||
|
||||
# --hints--
|
||||
|
||||
You should declare an `adjective` variable.
|
||||
@@ -142,12 +149,10 @@ assert.match(
|
||||
);
|
||||
```
|
||||
|
||||
You should log your first story using the message `"First story: [firstStory]"`.
|
||||
You should log your first story to the console using the message `"First story: [firstStory]"`.
|
||||
|
||||
```js
|
||||
const condition1 = /console\.log\(\s*["']First\s+story:\s+["']\s*\+\s*firstStory\s*\);?/gm.test(code);
|
||||
const condition2 = /console\.log\(\s*`First\s+story:\s+\$\{firstStory\}`\s*\);?/gm.test(code);
|
||||
assert.isTrue(condition1 || condition2);
|
||||
assert.include(getLogs(), `First story: ${firstStory}`);
|
||||
```
|
||||
|
||||
You should declare a `secondStory` variable.
|
||||
@@ -208,15 +213,13 @@ assert.match(
|
||||
);
|
||||
```
|
||||
|
||||
You should log your second story using the format `"Second story: [secondStory]"`.
|
||||
You should log your second story to the console using the message `"Second story: [secondStory]"`.
|
||||
|
||||
```js
|
||||
const condition1 = /console\.log\(\s*["']Second\s+story:\s+["']\s*\+\s*secondStory\s*\);?/gm.test(code);
|
||||
const condition2 = /console\.log\(\s*`Second\s+story:\s+\$\{secondStory\}`\s*\);?/gm.test(code);
|
||||
assert.isTrue(condition1 || condition2);
|
||||
assert.include(getLogs(), `Second story: ${secondStory}`);
|
||||
```
|
||||
|
||||
The `firstStory` should not be the same as the `secondStory`.
|
||||
Your `firstStory` should not be the same as your `secondStory`.
|
||||
|
||||
```js
|
||||
assert.notEqual(firstStory, secondStory);
|
||||
|
||||
Reference in New Issue
Block a user