diff --git a/client/i18n/locales/english/intro.json b/client/i18n/locales/english/intro.json index 68764477eb6..e6ae3a7974a 100644 --- a/client/i18n/locales/english/intro.json +++ b/client/i18n/locales/english/intro.json @@ -1936,7 +1936,12 @@ ] }, "hqba": { "title": "153", "intro": [] }, - "nnqa": { "title": "154", "intro": [] }, + "lab-sentence-maker": { + "title": "Build a Sentence Maker", + "intro": [ + "In this lab, you will create different stories by assigning different words to different variables." + ] + }, "cktz": { "title": "155", "intro": [] }, "pljo": { "title": "156", "intro": [] }, "avln": { "title": "157", "intro": [] }, diff --git a/client/src/pages/learn/front-end-development/lab-sentence-maker/index.md b/client/src/pages/learn/front-end-development/lab-sentence-maker/index.md new file mode 100644 index 00000000000..4d14ee92569 --- /dev/null +++ b/client/src/pages/learn/front-end-development/lab-sentence-maker/index.md @@ -0,0 +1,9 @@ +--- +title: Introduction to the Build a Sentence Maker +block: lab-sentence-maker +superBlock: front-end-development +--- + +## Introduction to Build a Sentence Maker + +In this lab, you will create different stories by assigning different words to different variables. diff --git a/curriculum/challenges/_meta/lab-sentence-maker/meta.json b/curriculum/challenges/_meta/lab-sentence-maker/meta.json new file mode 100644 index 00000000000..26f7d1937d0 --- /dev/null +++ b/curriculum/challenges/_meta/lab-sentence-maker/meta.json @@ -0,0 +1,11 @@ +{ + "name": "Build a Sentence Maker", + "isUpcomingChange": true, + "usesMultifileEditor": true, + "blockType": "lab", + "dashedName": "lab-sentence-maker", + "order": 154, + "superBlock": "front-end-development", + "challengeOrder": [{ "id": "66c057041df6394ca796bf33", "title": "Build a Sentence Maker" }], + "helpCategory": "JavaScript" +} diff --git a/curriculum/challenges/english/25-front-end-development/lab-sentence-maker/66c057041df6394ca796bf33.md b/curriculum/challenges/english/25-front-end-development/lab-sentence-maker/66c057041df6394ca796bf33.md new file mode 100644 index 00000000000..3963688d8b4 --- /dev/null +++ b/curriculum/challenges/english/25-front-end-development/lab-sentence-maker/66c057041df6394ca796bf33.md @@ -0,0 +1,226 @@ +--- +id: 66c057041df6394ca796bf33 +title: Build a Sentence Maker +challengeType: 14 +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. + +**Objective:** Fulfill the user stories below and get all the tests to pass to complete the lab. + +**User Stories:** + +1. You should declare the following variables using `let`: + +- `adjective` +- `noun` +- `verb` +- `place` +- `adjective2` +- `noun2` + +1. You should assign the above variables some string values of your choice. + +2. You should declare a `firstStory` variable using `const` to store the first story. + +3. 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 assign new values to your `adjective`, `noun`, `verb`, `place`, `adjective2`, and `noun2` variables. + +1. 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]"`. + + +# --hints-- + +You should declare an `adjective` variable. + +```js +assert.isNotNull(adjective); +``` + +You should declare a `noun` variable. + +```js +assert.isNotNull(noun); +``` + +You should declare a `verb` variable. + +```js +assert.isNotNull(verb); +``` + +You should declare a `place` variable. + +```js +assert.isNotNull(place); +``` + +You should declare an `adjective2` variable. + +```js +assert.isNotNull(adjective2); +``` + +You should declare a `noun2` variable. + +```js +assert.isNotNull(noun2); +``` + +You should assign a string value to the `adjective` variable. + +```js +assert.isString(adjective); +``` + +You should assign a string value to the `noun` variable. + +```js +assert.isString(noun); +``` + +You should assign a string value to the `verb` variable. + +```js +assert.isString(verb); +``` + +You should assign a string value to the `place` variable. + +```js +assert.isString(place); +``` + +You should assign a string value to the `adjective2` variable. + +```js +assert.isString(adjective2); +``` + +You should assign a string value to the `noun2` variable. + +```js +assert.isString(noun2); +``` + +You should declare a `firstStory` variable. + +```js +assert.isNotNull(firstStory); +``` + +Your should use the correct story format for both stories: `"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]."`. Pay attention to spaces. + +```js +const expected = `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}.`; +assert.strictEqual(secondStory, expected); +``` + +You should log your first story 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); +``` + +You should declare a `secondStory` variable. + +```js +assert.isNotNull(secondStory); +``` + +You should reassign the `adjective` variable for the second story. + +```js +assert.lengthOf(__helpers.removeJSComments(code).match(/adjective\s*=\s*/g), 2); +``` + +You should reassign the `noun` variable for the second story. + +```js +assert.lengthOf(__helpers.removeJSComments(code).match(/noun\s*=\s*/g), 2); +``` + +You should reassign the `verb` variable for the second story. + +```js +assert.lengthOf(__helpers.removeJSComments(code).match(/verb\s*=\s*/g), 2); +``` + +You should reassign the `place` variable for the second story. + +```js +assert.lengthOf(__helpers.removeJSComments(code).match(/place\s*=\s*/g), 2); +``` + +You should reassign the `adjective2` variable for the second story. + +```js +assert.lengthOf(__helpers.removeJSComments(code).match(/adjective2\s*=\s*/g), 2); +``` + +You should reassign the `noun2` variable for the second story. + +```js +assert.lengthOf(__helpers.removeJSComments(code).match(/noun2\s*=\s*/g), 2); +``` + +You should log your second story using the format `"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); +``` + +The `firstStory` should not be the same as the `secondStory`. + +```js +assert.notEqual(firstStory, secondStory); +``` + +# --seed-- + +## --seed-contents-- + +```js + +``` + +# --solutions-- + +```js +let adjective = "funny"; +let noun = "dragon"; +let verb = "jumping"; +let place = "garden"; +let adjective2 = "sparkling"; +let noun2 = "cakes"; + +const firstStory = `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}.`; + +console.log("First story: " + firstStory); + +adjective = "cute"; +noun = "puppy"; +verb = "barking"; +place = "park"; +adjective2 = "colorful"; +noun2 = "flower"; + +const secondStory = `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}.`; + +console.log("Second story: " + secondStory); +``` +