mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-04-18 10:00:55 -04:00
fix(curriculum): rework variable declarations in Greeting Bot workshop (#61783)
Co-authored-by: Ilenia M <nethleen@gmail.com>
This commit is contained in:
@@ -7,30 +7,30 @@ dashedName: step-4
|
||||
|
||||
# --description--
|
||||
|
||||
When you need to declare variables with multiple words, you can use the <dfn>camelCase</dfn> naming convention.
|
||||
Now, it is time to assign a value to your `bot` variable.
|
||||
|
||||
When using `camelCase`, the first word is all lowercase and the first letter of each subsequent word is capitalized.
|
||||
|
||||
Here is an example:
|
||||
In the previous lectures, you learned how to assign values to variables like this:
|
||||
|
||||
```js
|
||||
let thisIsCamelCase;
|
||||
variableName = "Here is the value";
|
||||
```
|
||||
|
||||
Use `let` to declare a variable named `botLocation`.
|
||||
Remember that what is on the right side of the assignment operator `=` is the value that you are assigning to the variable on the left side.
|
||||
|
||||
Assign the string `"teacherBot"` to the `bot` variable.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should use `let` to declare the variable.
|
||||
You should assign a string to your `bot` variable.
|
||||
|
||||
```js
|
||||
assert.lengthOf(code.match(/let/g), 2);
|
||||
assert.isString(bot);
|
||||
```
|
||||
|
||||
Your variable should be named `botLocation`.
|
||||
Your `bot` variable should be assigned the string `"teacherBot"`.
|
||||
|
||||
```js
|
||||
assert.isNotNull(botLocation);
|
||||
assert.equal(bot, "teacherBot");
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -7,30 +7,32 @@ dashedName: step-5
|
||||
|
||||
# --description--
|
||||
|
||||
Now, it is time to assign some values to your `bot` and `botLocation` variables.
|
||||
Now, it is time to initialize the `botLocation` variable.
|
||||
|
||||
In the previous lectures, you learned how to assign values to variables like this:
|
||||
When you need to declare variables with multiple words, you can use the <dfn>camelCase</dfn> naming convention.
|
||||
|
||||
When using `camelCase`, the first word is all lowercase and the first letter of each subsequent word is capitalized.
|
||||
|
||||
Here is an example:
|
||||
|
||||
```js
|
||||
variableName = "Here is the value";
|
||||
let thisIsCamelCase = "Alice the camel is actually a horse.";
|
||||
```
|
||||
|
||||
Remember that what is on the right side of the assignment operator `=` is the value that you are assigning to the variable on the left side.
|
||||
|
||||
Assign the string `"teacherBot"` to the `bot` variable and the string `"the universe"` to the `botLocation` variable.
|
||||
Declare and assign the string `"the universe"` to the `botLocation` variable on the same line using the `let` keyword.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should assign a string to your `bot` variable.
|
||||
Use the `let` keyword to declare a variable.
|
||||
|
||||
```js
|
||||
assert.isString(bot);
|
||||
assert.lengthOf(__helpers.removeJSComments(code).match(/let/g), 2);
|
||||
```
|
||||
|
||||
Your `bot` variable should be assigned the string `"teacherBot"`.
|
||||
Your variable should be named `botLocation`.
|
||||
|
||||
```js
|
||||
assert.equal(bot, "teacherBot");
|
||||
assert.isNotNull(botLocation);
|
||||
```
|
||||
|
||||
You should assign a string to your `botLocation` variable.
|
||||
@@ -52,9 +54,8 @@ assert.equal(botLocation, "the universe");
|
||||
```js
|
||||
console.log("Hi there!");
|
||||
console.log("I am excited to talk to you.");
|
||||
|
||||
let bot;
|
||||
let botLocation;
|
||||
bot = "teacherBot";
|
||||
|
||||
--fcc-editable-region--
|
||||
|
||||
|
||||
@@ -32,12 +32,10 @@ assert.match(__helpers.removeJSComments(code), /("|')Allow\s+me\s+to\s+introduce
|
||||
```js
|
||||
console.log("Hi there!");
|
||||
console.log("I am excited to talk to you.");
|
||||
|
||||
let bot;
|
||||
let botLocation;
|
||||
|
||||
bot = "teacherBot";
|
||||
botLocation = "the universe";
|
||||
|
||||
let botLocation = "the universe";
|
||||
|
||||
--fcc-editable-region--
|
||||
|
||||
|
||||
@@ -67,12 +67,10 @@ assert.match(__helpers.removeJSComments(code), /console\.log\s*\(\s*botIntroduct
|
||||
```js
|
||||
console.log("Hi there!");
|
||||
console.log("I am excited to talk to you.");
|
||||
|
||||
let bot;
|
||||
let botLocation;
|
||||
|
||||
bot = "teacherBot";
|
||||
botLocation = "the universe";
|
||||
|
||||
let botLocation = "the universe";
|
||||
|
||||
console.log("Allow me to introduce myself.");
|
||||
|
||||
|
||||
@@ -56,12 +56,10 @@ assert.match(__helpers.removeJSComments(code), /console\.log\s*\(\s*botLocationS
|
||||
```js
|
||||
console.log("Hi there!");
|
||||
console.log("I am excited to talk to you.");
|
||||
|
||||
let bot;
|
||||
let botLocation;
|
||||
|
||||
bot = "teacherBot";
|
||||
botLocation = "the universe";
|
||||
|
||||
let botLocation = "the universe";
|
||||
|
||||
console.log("Allow me to introduce myself.");
|
||||
|
||||
|
||||
@@ -34,12 +34,10 @@ assert.strictEqual(bot, "professorBot");
|
||||
```js
|
||||
console.log("Hi there!");
|
||||
console.log("I am excited to talk to you.");
|
||||
|
||||
let bot;
|
||||
let botLocation;
|
||||
|
||||
bot = "teacherBot";
|
||||
botLocation = "the universe";
|
||||
|
||||
let botLocation = "the universe";
|
||||
|
||||
console.log("Allow me to introduce myself.");
|
||||
|
||||
|
||||
@@ -56,12 +56,10 @@ assert.match(__helpers.removeJSComments(code), /console\.log\s*\(\s*nicknameIntr
|
||||
```js
|
||||
console.log("Hi there!");
|
||||
console.log("I am excited to talk to you.");
|
||||
|
||||
let bot;
|
||||
let botLocation;
|
||||
|
||||
bot = "teacherBot";
|
||||
botLocation = "the universe";
|
||||
|
||||
let botLocation = "the universe";
|
||||
|
||||
console.log("Allow me to introduce myself.");
|
||||
|
||||
|
||||
@@ -26,12 +26,10 @@ assert.strictEqual(bot, "awesomeTeacherBot");
|
||||
```js
|
||||
console.log("Hi there!");
|
||||
console.log("I am excited to talk to you.");
|
||||
|
||||
let bot;
|
||||
let botLocation;
|
||||
|
||||
bot = "teacherBot";
|
||||
botLocation = "the universe";
|
||||
|
||||
let botLocation = "the universe";
|
||||
|
||||
console.log("Allow me to introduce myself.");
|
||||
|
||||
|
||||
@@ -56,12 +56,10 @@ assert.match(__helpers.removeJSComments(code), /console\.log\s*\(\s*newNicknameG
|
||||
```js
|
||||
console.log("Hi there!");
|
||||
console.log("I am excited to talk to you.");
|
||||
|
||||
let bot;
|
||||
let botLocation;
|
||||
|
||||
bot = "teacherBot";
|
||||
botLocation = "the universe";
|
||||
|
||||
let botLocation = "the universe";
|
||||
|
||||
console.log("Allow me to introduce myself.");
|
||||
|
||||
|
||||
@@ -38,12 +38,10 @@ assert.strictEqual(favoriteSubject, "Computer Science");
|
||||
```js
|
||||
console.log("Hi there!");
|
||||
console.log("I am excited to talk to you.");
|
||||
|
||||
let bot;
|
||||
let botLocation;
|
||||
|
||||
bot = "teacherBot";
|
||||
botLocation = "the universe";
|
||||
|
||||
let botLocation = "the universe";
|
||||
|
||||
console.log("Allow me to introduce myself.");
|
||||
|
||||
|
||||
@@ -54,12 +54,10 @@ assert.match(__helpers.removeJSComments(code), /console\.log\s*\(\s*favoriteSubj
|
||||
```js
|
||||
console.log("Hi there!");
|
||||
console.log("I am excited to talk to you.");
|
||||
|
||||
let bot;
|
||||
let botLocation;
|
||||
|
||||
bot = "teacherBot";
|
||||
botLocation = "the universe";
|
||||
|
||||
let botLocation = "the universe";
|
||||
|
||||
console.log("Allow me to introduce myself.");
|
||||
|
||||
|
||||
@@ -33,12 +33,10 @@ assert.match(__helpers.removeJSComments(code), /console\.log\s*\(\s*["']Well\s*,
|
||||
```js
|
||||
console.log("Hi there!");
|
||||
console.log("I am excited to talk to you.");
|
||||
|
||||
let bot;
|
||||
let botLocation;
|
||||
|
||||
bot = "teacherBot";
|
||||
botLocation = "the universe";
|
||||
|
||||
let botLocation = "the universe";
|
||||
|
||||
console.log("Allow me to introduce myself.");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user