mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
chore(curriculum): add quotes around strings in Role Playing Game (#53523)
This commit is contained in:
+1
-1
@@ -11,7 +11,7 @@ One of the most powerful tools is your developer console. Depending on your brow
|
||||
|
||||
The developer console will include errors that are produced by your code, but you can also use it to see values of variables in your code, which is helpful for debugging.
|
||||
|
||||
Add a `console.log("Hello World");` line between your `script` tags. Then click the "Console" button to open the console. You should see the text `Hello World`.
|
||||
Add a `console.log("Hello World");` line between your `script` tags. Then click the "Console" button to open the console. You should see the text `"Hello World"`.
|
||||
|
||||
Note how the line ends with a semi-colon. It is common practice in JavaScript to end your code lines with semi-colons.
|
||||
|
||||
|
||||
+4
-4
@@ -15,7 +15,7 @@ let order = ["first", "second", "third"];
|
||||
|
||||
This is an array which holds three values. Notice how the values are separated by commas.
|
||||
|
||||
Change your `inventory` variable to be an array with the strings `stick`, `dagger`, and `sword`.
|
||||
Change your `inventory` variable to be an array with the strings `"stick"`, `"dagger"`, and `"sword"`.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -31,19 +31,19 @@ Your `inventory` variable should have three values.
|
||||
assert.lengthOf(inventory, 3);
|
||||
```
|
||||
|
||||
Your `inventory` variable should include the string `stick`.
|
||||
Your `inventory` variable should include the string `"stick"`.
|
||||
|
||||
```js
|
||||
assert.include(inventory, "stick");
|
||||
```
|
||||
|
||||
Your `inventory` variable should include the string `dagger`.
|
||||
Your `inventory` variable should include the string `"dagger"`.
|
||||
|
||||
```js
|
||||
assert.include(inventory, "dagger");
|
||||
```
|
||||
|
||||
Your `inventory` variable should include the string `sword`.
|
||||
Your `inventory` variable should include the string `"sword"`.
|
||||
|
||||
```js
|
||||
assert.include(inventory, "sword");
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@ dashedName: step-14
|
||||
|
||||
# --description--
|
||||
|
||||
For now, you want the player to start with just the `stick`. Change the `inventory` array to have `stick` as its only value.
|
||||
For now, you want the player to start with just the `"stick"`. Change the `inventory` array to have `"stick"` as its only value.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -23,7 +23,7 @@ Your `inventory` variable should only have one value.
|
||||
assert.lengthOf(inventory, 1);
|
||||
```
|
||||
|
||||
Your `inventory` variable should include the string `stick`.
|
||||
Your `inventory` variable should include the string `"stick"`.
|
||||
|
||||
```js
|
||||
assert.include(inventory, "stick");
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ You should use `document.querySelector()`.
|
||||
assert.match(code, /document\.querySelector/);
|
||||
```
|
||||
|
||||
You should use the `#button1` selector.
|
||||
You should use the `"#button1"` selector.
|
||||
|
||||
```js
|
||||
assert.match(code, /querySelector\(\s*('|")#button1\1\s*\)/);
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ dashedName: step-36
|
||||
|
||||
# --description--
|
||||
|
||||
For now, make your `goStore` function output the message `Going to store.` to the console. For example, here is a function that outputs the message `Hello World`.
|
||||
For now, make your `goStore` function output the message `"Going to store."` to the console. For example, here is a function that outputs the message `"Hello World"`.
|
||||
|
||||
```js
|
||||
function functionName() {
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ dashedName: step-37
|
||||
|
||||
# --description--
|
||||
|
||||
Now create a `goCave` function that prints `Going to cave.` to the console.
|
||||
Now create a `goCave` function that prints `"Going to cave."` to the console.
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ dashedName: step-38
|
||||
|
||||
# --description--
|
||||
|
||||
Now create a `fightDragon` function that prints `Fighting dragon.` to the console.
|
||||
Now create a `fightDragon` function that prints `"Fighting dragon."` to the console.
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
+2
-2
@@ -14,9 +14,9 @@ const info = document.querySelector("#info");
|
||||
info.innerText = "Hello World";
|
||||
```
|
||||
|
||||
This code would change the element assigned to the `info` variable to have the text `Hello World`.
|
||||
This code would change the element assigned to the `info` variable to have the text `"Hello World"`.
|
||||
|
||||
When a player clicks your `Go to store` button, you want to change the buttons and text. Remove the code inside the `goStore` function and add a line that updates the text of `button1` to say `Buy 10 health (10 gold)`.
|
||||
When a player clicks your `Go to store` button, you want to change the buttons and text. Remove the code inside the `goStore` function and add a line that updates the text of `button1` to say `"Buy 10 health (10 gold)"`.
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
+3
-3
@@ -7,7 +7,7 @@ dashedName: step-43
|
||||
|
||||
# --description--
|
||||
|
||||
Now, add a line that updates the text of `button2` to say `Buy weapon (30 gold)` and update the text of `button3` to say `Go to town square`.
|
||||
Now, add a line that updates the text of `button2` to say `"Buy weapon (30 gold)"` and update the text of `button3` to say `"Go to town square"`.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -23,7 +23,7 @@ You should not use `let` or `const` to access the `innerText` property of `butto
|
||||
assert.notMatch(code, /(let|const)\s+button2\.innerText/);
|
||||
```
|
||||
|
||||
You should update the `innerText` property of `button2` to be `Buy weapon (30 gold)`.
|
||||
You should update the `innerText` property of `button2` to be `"Buy weapon (30 gold)"`.
|
||||
|
||||
```js
|
||||
assert.match(code, /button2\.innerText\s*=\s*('|")Buy weapon \(30 gold\)\1/);
|
||||
@@ -47,7 +47,7 @@ You should not use `let` or `const` to access the `innerText` property of `butto
|
||||
assert.notMatch(code, /(let|const)\s+button3\.innerText/);
|
||||
```
|
||||
|
||||
You should update the `innerText` property of `button3` to be `Go to town square`.
|
||||
You should update the `innerText` property of `button3` to be `"Go to town square"`.
|
||||
|
||||
```js
|
||||
assert.match(code, /button3\.innerText\s*=\s*('|")Go to town square\1/);
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@ dashedName: step-45
|
||||
|
||||
# --description--
|
||||
|
||||
Now you need to modify your display text. Change the `innerText` property of the `text` to be `You enter the store.`.
|
||||
Now you need to modify your display text. Change the `innerText` property of the `text` to be `"You enter the store."`.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -23,7 +23,7 @@ You should not use `let` or `const` to access the `innerText` property of `text`
|
||||
assert.notMatch(code, /(let|const)\s+text\.innerText/);
|
||||
```
|
||||
|
||||
You should update the `innerText` property of `text` to be `You enter the store.`.
|
||||
You should update the `innerText` property of `text` to be `"You enter the store."`.
|
||||
|
||||
```js
|
||||
assert.match(code, /text\.innerText\s*=\s*('|")You enter the store.\1/);
|
||||
|
||||
+6
-6
@@ -7,25 +7,25 @@ dashedName: step-48
|
||||
|
||||
# --description--
|
||||
|
||||
In your `goTown` function, change your `button` elements' `innerText` properties to be `Go to store`, `Go to cave`, and `Fight dragon`. Update your `onclick` properties to be `goStore`, `goCave`, and `fightDragon`, respectively.
|
||||
In your `goTown` function, change your `button` elements' `innerText` properties to be `"Go to store"`, `"Go to cave"`, and `"Fight dragon"`. Update your `onclick` properties to be `goStore`, `goCave`, and `fightDragon`, respectively.
|
||||
|
||||
Finally, update `innerText` property of your `text` to be `You are in the town square. You see a sign that says Store.`.
|
||||
Finally, update `innerText` property of your `text` to be `"You are in the town square. You see a sign that says Store."`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should set the `button1.innerText` property to be `Go to store` in your `goTown` function.
|
||||
You should set the `button1.innerText` property to be `"Go to store"` in your `goTown` function.
|
||||
|
||||
```js
|
||||
assert.match(goTown.toString(), /button1\.innerText\s*=\s*('|")Go to store\1/);
|
||||
```
|
||||
|
||||
You should set the `button2.innerText` property to be `Go to cave` in your `goTown` function.
|
||||
You should set the `button2.innerText` property to be `"Go to cave"` in your `goTown` function.
|
||||
|
||||
```js
|
||||
assert.match(goTown.toString(), /button2\.innerText\s*=\s*('|")Go to cave\1/);
|
||||
```
|
||||
|
||||
You should set the `button3.innerText` property to be `Fight dragon` in your `goTown` function.
|
||||
You should set the `button3.innerText` property to be `"Fight dragon"` in your `goTown` function.
|
||||
|
||||
```js
|
||||
assert.match(goTown.toString(), /button3\.innerText\s*=\s*('|")Fight dragon\1/);
|
||||
@@ -49,7 +49,7 @@ You should set the `button3.onclick` property to be `fightDragon` in your `goTow
|
||||
assert.match(goTown.toString(), /button3\.onclick\s*=\s*fightDragon/);
|
||||
```
|
||||
|
||||
You should set the `text.innerText` property to be `You are in the town square. You see a sign that says Store.` in your `goTown` function.
|
||||
You should set the `text.innerText` property to be `"You are in the town square. You see a sign that says Store."` in your `goTown` function.
|
||||
|
||||
```js
|
||||
assert.match(goTown.toString(), /text\.innerText\s*=\s*('|")You are in the town square. You see a sign that says Store\.\1/);
|
||||
|
||||
+3
-3
@@ -7,7 +7,7 @@ dashedName: step-53
|
||||
|
||||
# --description--
|
||||
|
||||
Object <dfn>properties</dfn> are written as `key: value` pairs, where `key` is the name of the property (or the key), and `value` is the value that property holds. For example, here is an object with a key of `name` set to `Quincy Larson`.
|
||||
Object <dfn>properties</dfn> are written as `key: value` pairs, where `key` is the name of the property (or the key), and `value` is the value that property holds. For example, here is an object with a key of `name` set to `"Quincy Larson"`.
|
||||
|
||||
```js
|
||||
{
|
||||
@@ -15,7 +15,7 @@ Object <dfn>properties</dfn> are written as `key: value` pairs, where `key` is t
|
||||
}
|
||||
```
|
||||
|
||||
Add a `name` property to your empty object and give it a value of `town square`.
|
||||
Add a `name` property to your empty object and give it a value of `"town square"`.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -31,7 +31,7 @@ Your first value of `locations` should have a `name` property.
|
||||
assert.isDefined(locations[0].name);
|
||||
```
|
||||
|
||||
Your first value of `locations` should have a `name` property with a value of `town square`.
|
||||
Your first value of `locations` should have a `name` property with a value of `"town square"`.
|
||||
|
||||
```js
|
||||
assert.equal(locations[0].name, "town square");
|
||||
|
||||
+3
-3
@@ -25,19 +25,19 @@ assert.isString(locations[0]["button text"][1]);
|
||||
assert.isString(locations[0]["button text"][2]);
|
||||
```
|
||||
|
||||
The first value in the `button text` array should be "Go to store".
|
||||
The first value in the `button text` array should be `"Go to store"`.
|
||||
|
||||
```js
|
||||
assert.equal(locations[0]["button text"][0], "Go to store");
|
||||
```
|
||||
|
||||
The second value in the `button text` array should be "Go to cave".
|
||||
The second value in the `button text` array should be `"Go to cave"`.
|
||||
|
||||
```js
|
||||
assert.equal(locations[0]["button text"][1], "Go to cave");
|
||||
```
|
||||
|
||||
The third value in the `button text` array should be "Fight dragon".
|
||||
The third value in the `button text` array should be `"Fight dragon"`.
|
||||
|
||||
```js
|
||||
assert.equal(locations[0]["button text"][2], "Fight dragon");
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ Your `text` property should be a string.
|
||||
assert.isString(locations[0]["text"]);
|
||||
```
|
||||
|
||||
Your `text` property should have the value `You are in the town square. You see a sign that says \"Store\".`
|
||||
Your `text` property should have the value `"You are in the town square. You see a sign that says \"Store\"."`
|
||||
|
||||
```js
|
||||
assert.equal(locations[0]["text"], "You are in the town square. You see a sign that says \"Store\".");
|
||||
|
||||
+2
-2
@@ -37,7 +37,7 @@ Your second `locations` object should have a `button text` property which is an
|
||||
assert.isArray(locations[1]["button text"]);
|
||||
```
|
||||
|
||||
Your `button text` property should have the string values `Buy 10 health (10 gold)`, `Buy weapon (30 gold)`, and `Go to town square`.
|
||||
Your `button text` property should have the string values `"Buy 10 health (10 gold)"`, `"Buy weapon (30 gold)"`, and `"Go to town square"`.
|
||||
|
||||
```js
|
||||
assert.equal(locations[1]["button text"][0], "Buy 10 health (10 gold)");
|
||||
@@ -65,7 +65,7 @@ Your second `locations` object should have a `text` property which is a string.
|
||||
assert.isString(locations[1].text);
|
||||
```
|
||||
|
||||
Your second `locations` object should have a `text` property with the value of `You enter the store.`.
|
||||
Your second `locations` object should have a `text` property with the value of `"You enter the store."`.
|
||||
|
||||
```js
|
||||
assert.equal(locations[1].text, "You enter the store.");
|
||||
|
||||
+4
-4
@@ -11,19 +11,19 @@ Now you can consolidate some of your code. Start by copying the code from inside
|
||||
|
||||
# --hints--
|
||||
|
||||
Your `update` function should set `button1.innerText` to `Go to store`.
|
||||
Your `update` function should set `button1.innerText` to `"Go to store"`.
|
||||
|
||||
```js
|
||||
assert.match(update.toString(), /button1\.innerText\s*=\s*('|")Go to store\1/);
|
||||
```
|
||||
|
||||
Your `update` function should set `button2.innerText` to `Go to cave`.
|
||||
Your `update` function should set `button2.innerText` to `"Go to cave"`.
|
||||
|
||||
```js
|
||||
assert.match(update.toString(), /button2\.innerText\s*=\s*('|")Go to cave\1/);
|
||||
```
|
||||
|
||||
Your `update` function should set `button3.innerText` to `Fight dragon`.
|
||||
Your `update` function should set `button3.innerText` to `"Fight dragon"`.
|
||||
|
||||
```js
|
||||
assert.match(update.toString(), /button3\.innerText\s*=\s*('|")Fight dragon\1/);
|
||||
@@ -47,7 +47,7 @@ Your `update` function should set `button3.onclick` to `fightDragon`.
|
||||
assert.match(update.toString(), /button3\.onclick\s*=\s*fightDragon/);
|
||||
```
|
||||
|
||||
Your `update` function should set `text.innerText` to `You are in the town square. You see a sign that says \"Store\".`.
|
||||
Your `update` function should set `text.innerText` to `"You are in the town square. You see a sign that says \"Store\"."`.
|
||||
|
||||
```js
|
||||
assert.match(update.toString(), /text\.innerText\s*=\s*"You are in the town square. You see a sign that says \\"Store\\"\."/);
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ dashedName: step-62
|
||||
|
||||
# --description--
|
||||
|
||||
The `locations` array contains two locations: the `town square` and the `store`. Currently you are passing that entire array into the `update` function.
|
||||
The `locations` array contains two locations: the `"town square"` and the `"store"`. Currently you are passing that entire array into the `update` function.
|
||||
|
||||
Pass in only the first element of the `locations` array by adding `[0]` at the end of the variable. For example: `myFunction(arg[0]);`.
|
||||
|
||||
|
||||
+3
-3
@@ -9,17 +9,17 @@ dashedName: step-63
|
||||
|
||||
Now your `update` function needs to use the argument you pass into it.
|
||||
|
||||
Inside the `update` function, change the value of the `button1.innerText` assignment to be `location["button text"]`. That way, you use bracket notation to get the `button text` property of the `location` object passed into the function.
|
||||
Inside the `update` function, change the value of the `button1.innerText` assignment to be `location["button text"]`. That way, you use bracket notation to get the `"button text"` property of the `location` object passed into the function.
|
||||
|
||||
# --hints--
|
||||
|
||||
Your `update` function should use bracket notation to get the `button text` property of the `location` object passed into the function.
|
||||
Your `update` function should use bracket notation to get the `"button text"` property of the `location` object passed into the function.
|
||||
|
||||
```js
|
||||
assert.match(update.toString(), /location[('|")button text\1]/);
|
||||
```
|
||||
|
||||
You should assign the value of the `button text` property of the `location` object to the `innerText` property of `button1`.
|
||||
You should assign the value of the `"button text"` property of the `location` object to the `innerText` property of `button1`.
|
||||
|
||||
```js
|
||||
assert.match(update.toString(), /button1\.innerText\s*=\s*location\s*\[\s*('|")button text\1\s*\]/);
|
||||
|
||||
+2
-2
@@ -11,13 +11,13 @@ dashedName: step-64
|
||||
|
||||
# --hints--
|
||||
|
||||
You should access the first element of the `button text` property of the `location` parameter.
|
||||
You should access the first element of the `"button text"` property of the `location` parameter.
|
||||
|
||||
```js
|
||||
assert.match(update.toString(), /location\s*\[\s*('|")button text\1\s*\]\s*\[\s*0\s*\]/);
|
||||
```
|
||||
|
||||
You should set the `button1.innerText` property to be the first element of the `button text` property of the `location` parameter.
|
||||
You should set the `button1.innerText` property to be the first element of the `"button text"` property of the `location` parameter.
|
||||
|
||||
```js
|
||||
assert.match(update.toString(), /button1\.innerText\s*=\s*location\s*\[\s*('|")button text\1\s*\]\s*\[\s*0\s*\]/);
|
||||
|
||||
+5
-5
@@ -7,29 +7,29 @@ dashedName: step-65
|
||||
|
||||
# --description--
|
||||
|
||||
Now update `button2.innerText` and `button3.innerText` to be assigned the second and third values of the `button text` array, respectively.
|
||||
Now update `button2.innerText` and `button3.innerText` to be assigned the second and third values of the `"button text"` array, respectively.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should access the second element of the `button text` property of the `location` parameter.
|
||||
You should access the second element of the `"button text"` property of the `location` parameter.
|
||||
|
||||
```js
|
||||
assert.match(update.toString(), /location\s*\[\s*('|")button text\1\s*\]\s*\[\s*1\s*\]/);
|
||||
```
|
||||
|
||||
You should set the `button2.innerText` property to be the second element of the `button text` property of the `location` parameter.
|
||||
You should set the `button2.innerText` property to be the second element of the `"button text"` property of the `location` parameter.
|
||||
|
||||
```js
|
||||
assert.match(update.toString(), /button2\.innerText\s*=\s*location\s*\[\s*('|")button text\1\s*\]\s*\[\s*1\s*\]/);
|
||||
```
|
||||
|
||||
You should access the third element of the `button text` property of the `location` parameter.
|
||||
You should access the third element of the `"button text"` property of the `location` parameter.
|
||||
|
||||
```js
|
||||
assert.match(update.toString(), /location\s*\[\s*('|")button text\1\s*\]\s*\[\s*2\s*\]/);
|
||||
```
|
||||
|
||||
You should set the `button3.innerText` property to be the third element of the `button text` property of the `location` parameter.
|
||||
You should set the `button3.innerText` property to be the third element of the `"button text"` property of the `location` parameter.
|
||||
|
||||
```js
|
||||
assert.match(update.toString(), /button3\.innerText\s*=\s*location\s*\[\s*('|")button text\1\s*\]\s*\[\s*2\s*\]/);
|
||||
|
||||
+7
-7
@@ -7,41 +7,41 @@ dashedName: step-66
|
||||
|
||||
# --description--
|
||||
|
||||
Following the same pattern as you did for the button text, update the three buttons' `onclick` assignments to be the first, second, and third values of the `button functions` array.
|
||||
Following the same pattern as you did for the button text, update the three buttons' `onclick` assignments to be the first, second, and third values of the `"button functions"` array.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should access the first element of the `button functions` property of the `location` parameter.
|
||||
You should access the first element of the `"button functions"` property of the `location` parameter.
|
||||
|
||||
```js
|
||||
assert.match(update.toString(), /location\s*\[\s*('|")button functions\1\s*\]\s*\[\s*0\s*\]/);
|
||||
```
|
||||
|
||||
You should set the `button1.onclick` property to be the first element of the `button functions` property of the `location` parameter.
|
||||
You should set the `button1.onclick` property to be the first element of the `"button functions"` property of the `location` parameter.
|
||||
|
||||
```js
|
||||
assert.match(update.toString(), /button1\.onclick\s*=\s*location\s*\[\s*('|")button functions\1\s*\]\s*\[\s*0\s*\]/);
|
||||
```
|
||||
|
||||
You should access the second element of the `button functions` property of the `location` parameter.
|
||||
You should access the second element of the `"button functions"` property of the `location` parameter.
|
||||
|
||||
```js
|
||||
assert.match(update.toString(), /location\s*\[\s*('|")button functions\1\s*\]\s*\[\s*1\s*\]/);
|
||||
```
|
||||
|
||||
You should set the `button2.onclick` property to be the second element of the `button functions` property of the `location` parameter.
|
||||
You should set the `button2.onclick` property to be the second element of the `"button functions"` property of the `location` parameter.
|
||||
|
||||
```js
|
||||
assert.match(update.toString(), /button2\.onclick\s*=\s*location\s*\[\s*('|")button functions\1\s*\]\s*\[\s*1\s*\]/);
|
||||
```
|
||||
|
||||
You should access the third element of the `button functions` property of the `location` parameter.
|
||||
You should access the third element of the `"button functions"` property of the `location` parameter.
|
||||
|
||||
```js
|
||||
assert.match(update.toString(), /location\s*\[\s*('|")button functions\1\s*\]\s*\[\s*2\s*\]/);
|
||||
```
|
||||
|
||||
You should set the `button3.onclick` property to be the third element of the `button functions` property of the `location` parameter.
|
||||
You should set the `button3.onclick` property to be the third element of the `"button functions"` property of the `location` parameter.
|
||||
|
||||
```js
|
||||
assert.match(update.toString(), /button3\.onclick\s*=\s*location\s*\[\s*('|")button functions\1\s*\]\s*\[\s*2\s*\]/);
|
||||
|
||||
+7
-7
@@ -9,7 +9,7 @@ dashedName: step-70
|
||||
|
||||
Add a third object to the `locations` array. Give it the same properties as the other two objects.
|
||||
|
||||
Set `name` to `cave`. Set `button text` to an array with the strings `Fight slime`, `Fight fanged beast`, and `Go to town square`. Set the `button functions` to an array with the variables `fightSlime`, `fightBeast`, and `goTown`. Set the `text` property to `You enter the cave. You see some monsters.`.
|
||||
Set `name` to `cave`. Set `button text` to an array with the strings `"Fight slime"`, `"Fight fanged beast"`, and `"Go to town square"`. Set the `"button functions"` to an array with the variables `fightSlime`, `fightBeast`, and `goTown`. Set the `text` property to `"You enter the cave. You see some monsters."`.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -25,19 +25,19 @@ Your third `locations` value should be an object.
|
||||
assert.isObject(locations[2]);
|
||||
```
|
||||
|
||||
Your third `locations` object should have a `name` property with the value of `cave`.
|
||||
Your third `locations` object should have a `name` property with the value of `"cave"`.
|
||||
|
||||
```js
|
||||
assert.equal(locations[2].name, "cave");
|
||||
```
|
||||
|
||||
Your third `locations` object should have a `button text` property which is an array.
|
||||
Your third `locations` object should have a `"button text"` property which is an array.
|
||||
|
||||
```js
|
||||
assert.isArray(locations[2]["button text"]);
|
||||
```
|
||||
|
||||
Your `button text` property should have the string values `Fight slime`, `Fight fanged beast`, and `Go to town square`.
|
||||
Your `"button text"` property should have the string values `"Fight slime"`, `"Fight fanged beast"`, and `"Go to town square"`.
|
||||
|
||||
```js
|
||||
assert.equal(locations[2]["button text"][0], "Fight slime");
|
||||
@@ -45,13 +45,13 @@ assert.equal(locations[2]["button text"][1], "Fight fanged beast");
|
||||
assert.equal(locations[2]["button text"][2], "Go to town square");
|
||||
```
|
||||
|
||||
Your third `locations` object should have a `button functions` property which is an array.
|
||||
Your third `locations` object should have a `"button functions"` property which is an array.
|
||||
|
||||
```js
|
||||
assert.isArray(locations[2]["button functions"]);
|
||||
```
|
||||
|
||||
Your `button functions` property should have the function values `fightSlime`, `fightBeast`, and `goTown`.
|
||||
Your `"button functions"` property should have the function values `fightSlime`, `fightBeast`, and `goTown`.
|
||||
|
||||
```js
|
||||
assert.equal(locations[2]["button functions"][0], fightSlime);
|
||||
@@ -65,7 +65,7 @@ Your third `locations` object should have a `text` property which is a string.
|
||||
assert.isString(locations[2].text);
|
||||
```
|
||||
|
||||
Your third `locations` object should have a `text` property with the value of `You enter the cave. You see some monsters.`.
|
||||
Your third `locations` object should have a `text` property with the value of `"You enter the cave. You see some monsters."`.
|
||||
|
||||
```js
|
||||
assert.equal(locations[2].text, "You enter the cave. You see some monsters.");
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ dashedName: step-71
|
||||
|
||||
# --description--
|
||||
|
||||
Now that you have a `cave` location object, update your `goCave` function to call `update` and pass that new `cave` location. Remember that this is the third element in your `locations` array.
|
||||
Now that you have a `"cave"` location object, update your `goCave` function to call `update` and pass that new `"cave"` location. Remember that this is the third element in your `locations` array.
|
||||
|
||||
Don't forget to remove your `console.log` call!
|
||||
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ dashedName: step-72
|
||||
|
||||
# --description--
|
||||
|
||||
Now that your `store` and `cave` locations are complete, you can code the actions the player takes at those locations. Inside the `buyHealth` function, set `gold` equal to `gold` minus `10`.
|
||||
Now that your `"store"` and `"cave"` locations are complete, you can code the actions the player takes at those locations. Inside the `buyHealth` function, set `gold` equal to `gold` minus `10`.
|
||||
|
||||
For example, here is how you would set `num` equal to `5` less than `num`: `num = num - 5;`.
|
||||
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ const total = document.querySelector('#total');
|
||||
total.innerText = value;
|
||||
```
|
||||
|
||||
You can test this by clicking your "Go to store" button, followed by your "Buy Health" button.
|
||||
You can test this by clicking your `"Go to store"` button, followed by your `"Buy Health"` button.
|
||||
|
||||
**Note:** Your answer should only be two lines of code.
|
||||
|
||||
|
||||
+2
-2
@@ -7,11 +7,11 @@ dashedName: step-79
|
||||
|
||||
# --description--
|
||||
|
||||
Inside the `else` statement, set `text.innerText` to equal `You do not have enough gold to buy health.`.
|
||||
Inside the `else` statement, set `text.innerText` to equal `"You do not have enough gold to buy health."`.
|
||||
|
||||
# --hints--
|
||||
|
||||
Your `buyHealth` function should set `text.innerText` to equal `You do not have enough gold to buy health.`.
|
||||
Your `buyHealth` function should set `text.innerText` to equal `"You do not have enough gold to buy health."`.
|
||||
|
||||
```js
|
||||
assert.match(buyHealth.toString(), /text\.innerText\s*=\s*('|")You do not have enough gold to buy health\.\1/);
|
||||
|
||||
+5
-5
@@ -7,7 +7,7 @@ dashedName: step-81
|
||||
|
||||
# --description--
|
||||
|
||||
Just like your `locations` array, your `weapons` array will hold objects. Add four objects to the `weapons` array, each with two properties: `name` and `power`. The first should have the `name` set to `stick` and the `power` set to `5`. The second should be `dagger` and `30`. The third, `claw hammer` and `50`. The fourth, `sword` and `100`.
|
||||
Just like your `locations` array, your `weapons` array will hold objects. Add four objects to the `weapons` array, each with two properties: `name` and `power`. The first should have the `name` set to `"stick"` and the `power` set to `5`. The second should be `"dagger"` and `30`. The third, `"claw hammer"` and `50`. The fourth, `"sword"` and `100`.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -26,28 +26,28 @@ assert.isObject(weapons[2]);
|
||||
assert.isObject(weapons[3]);
|
||||
```
|
||||
|
||||
Your first `weapons` object should have the `name` set to `stick` and the `power` set to `5`.
|
||||
Your first `weapons` object should have the `name` set to `"stick"` and the `power` set to `5`.
|
||||
|
||||
```js
|
||||
assert.equal(weapons[0].name, 'stick');
|
||||
assert.equal(weapons[0].power, 5);
|
||||
```
|
||||
|
||||
Your second `weapons` object should have the `name` set to `dagger` and the `power` set to `30`.
|
||||
Your second `weapons` object should have the `name` set to `"dagger"` and the `power` set to `30`.
|
||||
|
||||
```js
|
||||
assert.equal(weapons[1].name, 'dagger');
|
||||
assert.equal(weapons[1].power, 30);
|
||||
```
|
||||
|
||||
Your third `weapons` object should have the `name` set to `claw hammer` and the `power` set to `50`.
|
||||
Your third `weapons` object should have the `name` set to `"claw hammer"` and the `power` set to `50`.
|
||||
|
||||
```js
|
||||
assert.equal(weapons[2].name, 'claw hammer');
|
||||
assert.equal(weapons[2].power, 50);
|
||||
```
|
||||
|
||||
Your fourth `weapons` object should have the `name` set to `sword` and the `power` set to `100`.
|
||||
Your fourth `weapons` object should have the `name` set to `"sword"` and the `power` set to `100`.
|
||||
|
||||
```js
|
||||
assert.equal(weapons[3].name, 'sword');
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ dashedName: step-84
|
||||
|
||||
# --description--
|
||||
|
||||
The value of the `currentWeapon` variable corresponds to an index in the `weapons` array. The player starts with a `stick`, since `currentWeapon` starts at `0` and `weapons[0]` is the `stick` weapon.
|
||||
The value of the `currentWeapon` variable corresponds to an index in the `weapons` array. The player starts with a `"stick"`, since `currentWeapon` starts at `0` and `weapons[0]` is the `"stick"` weapon.
|
||||
|
||||
In the `buyWeapon` function, use compound assignment to add `1` to `currentWeapon` - the user is buying the next weapon in the `weapons` array.
|
||||
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@ dashedName: step-86
|
||||
|
||||
# --description--
|
||||
|
||||
Now update the `goldText` element to display the new value of `gold`, and update the `text` element to display `You now have a new weapon.`.
|
||||
Now update the `goldText` element to display the new value of `gold`, and update the `text` element to display `"You now have a new weapon."`.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -17,7 +17,7 @@ You should update the `innerText` property of the `goldText` element to be `gold
|
||||
assert.match(buyWeapon.toString(), /goldText\.innerText\s*=\s*gold/);
|
||||
```
|
||||
|
||||
You should update the `innerText` property of the `text` element to be `You now have a new weapon.`.
|
||||
You should update the `innerText` property of the `text` element to be `"You now have a new weapon."`.
|
||||
|
||||
```js
|
||||
assert.match(buyWeapon.toString(), /text\.innerText\s*=\s*('|")You now have a new weapon\.\1/);
|
||||
|
||||
+3
-3
@@ -7,9 +7,9 @@ dashedName: step-90
|
||||
|
||||
# --description--
|
||||
|
||||
You can insert variables into a string with the <dfn>concatenation operator</dfn> `+`. Update the `You now have a new weapon.` string to say `You now have a ` and the name of the new weapon. Remember to end the sentence with a period.
|
||||
You can insert variables into a string with the <dfn>concatenation operator</dfn> `+`. Update the `"You now have a new weapon."` string to say `"You now have a "` and the name of the new weapon. Remember to end the sentence with a period.
|
||||
|
||||
Here is an example that creates the string `Hello, our name is freeCodeCamp.`:
|
||||
Here is an example that creates the string `"Hello, our name is freeCodeCamp."`:
|
||||
|
||||
```js
|
||||
const ourName = "freeCodeCamp";
|
||||
@@ -18,7 +18,7 @@ const ourStr = "Hello, our name is " + ourName + ".";
|
||||
|
||||
# --hints--
|
||||
|
||||
You should update the `text.innerText` assignment to start with the string `You now have a `.
|
||||
You should update the `text.innerText` assignment to start with the string `"You now have a "`.
|
||||
|
||||
```js
|
||||
assert.match(buyWeapon.toString(), /text\.innerText\s*=\s*('|")You now have a \1/);
|
||||
|
||||
+2
-2
@@ -9,7 +9,7 @@ dashedName: step-92
|
||||
|
||||
Up until now, any time `text.innerText` was updated, the old text was erased. This time, use the `+=` operator to add text to the end of `text.innerText`.
|
||||
|
||||
Add the string ` In your inventory you have: ` - include the spaces at the beginning and the end.
|
||||
Add the string `" In your inventory you have: "` - include the spaces at the beginning and the end.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -26,7 +26,7 @@ You should use the `+=` operator to add to `text.innerText`.
|
||||
assert.match(buyWeapon.toString(), /text\.innerText\s*\+=\s*/)
|
||||
```
|
||||
|
||||
You should add the string ` In your inventory you have: ` to the end of `text.innerText`. Mind the spaces!
|
||||
You should add the string `" In your inventory you have: "` to the end of `text.innerText`. Mind the spaces!
|
||||
|
||||
```js
|
||||
assert.match(buyWeapon.toString(), /text\.innerText\s*\+=\s*('|")\sIn your inventory you have:\s\1/)
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ At the end of the second `text.innerText` string you just added, use the concate
|
||||
|
||||
# --hints--
|
||||
|
||||
You should not change the ` In your inventory you have: ` string.
|
||||
You should not change the `" In your inventory you have: "` string.
|
||||
|
||||
```js
|
||||
assert.match(buyWeapon.toString(), /text\.innerText\s*\+=\s*('|")\sIn your inventory you have:\s\1/)
|
||||
|
||||
+3
-3
@@ -7,7 +7,7 @@ dashedName: step-94
|
||||
|
||||
# --description--
|
||||
|
||||
Add an `else` statement to your `buyWeapon` function. In that statement, set `text.innerText` to equal `You do not have enough gold to buy a weapon.`.
|
||||
Add an `else` statement to your `buyWeapon` function. In that statement, set `text.innerText` to equal `"You do not have enough gold to buy a weapon."`.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -24,13 +24,13 @@ const split = buyWeapon.toString().split(/\s|\n/);
|
||||
assert.isAbove(split.indexOf('else'), split.indexOf('if'));
|
||||
```
|
||||
|
||||
You should set `text.innerText` to `You do not have enough gold to buy a weapon.`.
|
||||
You should set `text.innerText` to `"You do not have enough gold to buy a weapon."`.
|
||||
|
||||
```js
|
||||
assert.match(buyWeapon.toString(), /text\.innerText\s*=\s*('|")You do not have enough gold to buy a weapon.\1/);
|
||||
```
|
||||
|
||||
Your `else` statement should set `text.innerText` to `You do not have enough gold to buy a weapon.`.
|
||||
Your `else` statement should set `text.innerText` to `"You do not have enough gold to buy a weapon."`.
|
||||
|
||||
```js
|
||||
gold = 20;
|
||||
|
||||
+3
-3
@@ -7,7 +7,7 @@ dashedName: step-98
|
||||
|
||||
# --description--
|
||||
|
||||
Add an `else` statement for your outer `if` statement. Inside this new `else` statement, set `text.innerText` to `You already have the most powerful weapon!`.
|
||||
Add an `else` statement for your outer `if` statement. Inside this new `else` statement, set `text.innerText` to `"You already have the most powerful weapon!"`.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -18,13 +18,13 @@ const matches = buyWeapon.toString().match(/else/g);
|
||||
assert.equal(matches.length, 2);
|
||||
```
|
||||
|
||||
You should set `text.innerText` to `You already have the most powerful weapon!`.
|
||||
You should set `text.innerText` to `"You already have the most powerful weapon!"`.
|
||||
|
||||
```js
|
||||
assert.match(buyWeapon.toString(), /('|")You already have the most powerful weapon!\1/);
|
||||
```
|
||||
|
||||
You should modify your `text.innerText` to `You already have the most powerful weapon!` within your outer `else` statement.
|
||||
You should modify your `text.innerText` to `"You already have the most powerful weapon!"` within your outer `else` statement.
|
||||
|
||||
```js
|
||||
currentWeapon = 5;
|
||||
|
||||
+2
-2
@@ -9,7 +9,7 @@ dashedName: step-99
|
||||
|
||||
Once a player has the most powerful weapon, you can give them the ability to sell their old weapons.
|
||||
|
||||
In the outer `else` statement, set `button2.innerText` to `Sell weapon for 15 gold`. Also set `button2.onclick` to the function name `sellWeapon`.
|
||||
In the outer `else` statement, set `button2.innerText` to `"Sell weapon for 15 gold"`. Also set `button2.onclick` to the function name `sellWeapon`.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -19,7 +19,7 @@ You should set the value of `button2.innerText`.
|
||||
assert.match(buyWeapon.toString(), /button2\.innerText/);
|
||||
```
|
||||
|
||||
You should set the value of `button2.innerText` to `Sell weapon for 15 gold`.
|
||||
You should set the value of `button2.innerText` to `"Sell weapon for 15 gold"`.
|
||||
|
||||
```js
|
||||
assert.match(buyWeapon.toString(), /button2\.innerText\s*=\s*('|")Sell weapon for 15 gold\1;/);
|
||||
|
||||
+4
-4
@@ -7,7 +7,7 @@ dashedName: step-105
|
||||
|
||||
# --description--
|
||||
|
||||
After your `currentWeapon`, use the concatenation operator to set `text.innerText` to the string `You sold a `, then `currentWeapon`, then the string `.`.
|
||||
After your `currentWeapon`, use the concatenation operator to set `text.innerText` to the string `"You sold a "`, then `currentWeapon`, then the string `"."`.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -17,19 +17,19 @@ You should use the assignment operator with `text.innerText`.
|
||||
assert.match(sellWeapon.toString(), /text\.innerText\s*=/);
|
||||
```
|
||||
|
||||
You should add `You sold a ` to `text.innerText`. Spacing is important.
|
||||
You should add `"You sold a "` to `text.innerText`. Spacing is important.
|
||||
|
||||
```js
|
||||
assert.match(sellWeapon.toString(), /text\.innerText\s*=\s*('|")You sold a \1/);
|
||||
```
|
||||
|
||||
You should add the value of `currentWeapon` to the `You sold a ` string. Use the concatenation operator to do this on the same line.
|
||||
You should add the value of `currentWeapon` to the `"You sold a "` string. Use the concatenation operator to do this on the same line.
|
||||
|
||||
```js
|
||||
assert.match(sellWeapon.toString(), /text\.innerText\s*=\s*('|")You sold a\s\1\s*\+\s*\_currentWeapon/);
|
||||
```
|
||||
|
||||
You should add the string `.` to the value of `currentWeapon`. Use the concatenation operator to do this on the same line.
|
||||
You should add the string `"."` to the value of `currentWeapon`. Use the concatenation operator to do this on the same line.
|
||||
|
||||
```js
|
||||
assert.match(sellWeapon.toString(), /text\.innerText\s*=\s*('|")You sold a \1\s*\+\s*\_currentWeapon\s+\+\s+('|")\.\2/);
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@ dashedName: step-106
|
||||
|
||||
# --description--
|
||||
|
||||
Now use the `+=` operator to add the string ` In your inventory you have: ` and the contents of `inventory` to the `text.innerText`. Make sure to include the space at the beginning and end of the ` In your inventory you have: ` string.
|
||||
Now use the `+=` operator to add the string `" In your inventory you have: "` and the contents of `inventory` to the `text.innerText`. Make sure to include the space at the beginning and end of the `" In your inventory you have: "` string.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -25,7 +25,7 @@ const matches = sellWeapon.toString().match(/text\.innerText\s*\+=/g);
|
||||
assert.equal(matches.length, 1);
|
||||
```
|
||||
|
||||
You should add the string ` In your inventory you have: ` to the second `text.innerText` line. Spacing matters.
|
||||
You should add the string `" In your inventory you have: "` to the second `text.innerText` line. Spacing matters.
|
||||
|
||||
```js
|
||||
assert.match(sellWeapon.toString(), /text\.innerText\s*\+=\s*('|") In your inventory you have: \1/);
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@ dashedName: step-107
|
||||
|
||||
# --description--
|
||||
|
||||
Use an `else` statement to run when the `inventory` length is not more than one. Set the `text.innerText` to say `Don't sell your only weapon!`.
|
||||
Use an `else` statement to run when the `inventory` length is not more than one. Set the `text.innerText` to say `"Don't sell your only weapon!"`.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -17,7 +17,7 @@ Your `sellWeapon` function should have an `else` statement.
|
||||
assert.match(sellWeapon.toString(), /else/);
|
||||
```
|
||||
|
||||
You should set `text.innerText` to `Don't sell your only weapon!`.
|
||||
You should set `text.innerText` to `"Don't sell your only weapon!"`.
|
||||
|
||||
```js
|
||||
assert.match(sellWeapon.toString(), /text\.innerText\s*=\s*('|")Don't sell your only weapon!\1/);
|
||||
|
||||
+4
-4
@@ -9,7 +9,7 @@ dashedName: step-108
|
||||
|
||||
Now you can start the code to fight monsters. To keep your code organized, your `fightDragon` function has been moved for you to be near the other `fight` functions.
|
||||
|
||||
Below your `weapons` array, define a `monsters` variable and assign it an array. Set that array to have three objects, each with a `name`, `level`, and `health` properties. The first object's values should be `slime`, `2`, and `15`, in order. The second should be `fanged beast`, `8`, and `60`. The third should be `dragon`, `20`, and `300`.
|
||||
Below your `weapons` array, define a `monsters` variable and assign it an array. Set that array to have three objects, each with a `name`, `level`, and `health` properties. The first object's values should be `"slime"`, `2`, and `15`, in order. The second should be `"fanged beast"`, `8`, and `60`. The third should be `"dragon"`, `20`, and `300`.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -37,7 +37,7 @@ Your `monsters` array should have 3 objects.
|
||||
assert(monsters.every(val => typeof val === "object"));
|
||||
```
|
||||
|
||||
The first value in your `monsters` array should be an object with a `name` property set to `slime`.
|
||||
The first value in your `monsters` array should be an object with a `name` property set to `"slime"`.
|
||||
|
||||
```js
|
||||
assert.equal(monsters[0].name, "slime");
|
||||
@@ -55,7 +55,7 @@ The first value in your `monsters` array should be an object with a `health` pro
|
||||
assert.equal(monsters[0].health, 15);
|
||||
```
|
||||
|
||||
The second value in your `monsters` array should be an object with a `name` property set to `fanged beast`.
|
||||
The second value in your `monsters` array should be an object with a `name` property set to `"fanged beast"`.
|
||||
|
||||
```js
|
||||
assert.equal(monsters[1].name, "fanged beast");
|
||||
@@ -73,7 +73,7 @@ The second value in your `monsters` array should be an object with a `health` pr
|
||||
assert.equal(monsters[1].health, 60);
|
||||
```
|
||||
|
||||
The third value in your `monsters` array should be an object with a `name` property set to `dragon`.
|
||||
The third value in your `monsters` array should be an object with a `name` property set to `"dragon"`.
|
||||
|
||||
```js
|
||||
assert.equal(monsters[2].name, "dragon");
|
||||
|
||||
+5
-5
@@ -7,7 +7,7 @@ dashedName: step-113
|
||||
|
||||
# --description--
|
||||
|
||||
Add a new object to the end of the `locations` array, following the same properties as the rest of the objects. Set `name` to `fight`, `button text` to an array with `Attack`, `Dodge`, and `Run`, `button functions` to an array with `attack`, `dodge`, and `goTown`, and `text` to `You are fighting a monster.`.
|
||||
Add a new object to the end of the `locations` array, following the same properties as the rest of the objects. Set `name` to `"fight"`, `"button text"` to an array with `"Attack"`, `"Dodge"`, and `"Run"`, `"button functions"` to an array with `attack`, `dodge`, and `goTown`, and `text` to `"You are fighting a monster."`.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -23,25 +23,25 @@ Your new value should be an object.
|
||||
assert.isObject(locations[3]);
|
||||
```
|
||||
|
||||
Your new object should have a `name` property set to `fight`.
|
||||
Your new object should have a `name` property set to `"fight"`.
|
||||
|
||||
```js
|
||||
assert.equal(locations[3].name, "fight");
|
||||
```
|
||||
|
||||
Your new object should have a `button text` property set to an array with the strings `Attack`, `Dodge`, and `Run`.
|
||||
Your new object should have a `"button text"` property set to an array with the strings `"Attack"`, `"Dodge"`, and `"Run"`.
|
||||
|
||||
```js
|
||||
assert.deepEqual(locations[3]["button text"], ["Attack", "Dodge", "Run"]);
|
||||
```
|
||||
|
||||
Your new object should have a `button functions` property set to an array with the variables `attack`, `dodge`, and `goTown`.
|
||||
Your new object should have a `"button functions"` property set to an array with the variables `attack`, `dodge`, and `goTown`.
|
||||
|
||||
```js
|
||||
assert.deepEqual(locations[3]["button functions"], [attack, dodge, goTown]);
|
||||
```
|
||||
|
||||
Your new object should have a `text` property set to `You are fighting a monster.`.
|
||||
Your new object should have a `text` property set to `"You are fighting a monster."`.
|
||||
|
||||
```js
|
||||
assert.equal(locations[3].text, "You are fighting a monster.");
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ dashedName: step-118
|
||||
|
||||
# --description--
|
||||
|
||||
Now you can build the `attack` function. First, update the `text` message to say `The <monster name> attacks.`, replacing `<monster name>` with the name of the monster. Remember you can use the concatenation operator for this.
|
||||
Now you can build the `attack` function. First, update the `text` message to say `"The <monster name> attacks."`, replacing `<monster name>` with the name of the monster. Remember you can use the concatenation operator for this.
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
+3
-3
@@ -7,7 +7,7 @@ dashedName: step-119
|
||||
|
||||
# --description--
|
||||
|
||||
On a new line, add the string ` You attack it with your <weapon>.` to the `text` value, replacing `<weapon>` with the player's current weapon. Additionally, remember that this line of text starts with a space so it will properly display.
|
||||
On a new line, add the string `" You attack it with your <weapon>."` to the `text` value, replacing `<weapon>` with the player's current weapon. Additionally, remember that this line of text starts with a space so it will properly display.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -24,7 +24,7 @@ You should use compound assignment with `text.innerText`.
|
||||
assert.match(attack.toString(), /text\.innerText\s*\+=/);
|
||||
```
|
||||
|
||||
You should add the string ` You attack it with your ` to the `text.innerText` value. Remember that spacing matters.
|
||||
You should add the string `" You attack it with your "` to the `text.innerText` value. Remember that spacing matters.
|
||||
|
||||
```js
|
||||
assert.match(attack.toString(), /text\.innerText\s*\+=\s*('|") You attack it with your \1/);
|
||||
@@ -36,7 +36,7 @@ You should use the concatenation operator to add the current weapon to the strin
|
||||
assert.match(attack.toString(), /text\.innerText\s*\+=\s*('|") You attack it with your \1\s*\+\s*weapons\s*\[\s*currentWeapon\s*\]\s*\.name/);
|
||||
```
|
||||
|
||||
You should use the concatenation operator to end your string with `.`.
|
||||
You should use the concatenation operator to end your string with `"."`.
|
||||
|
||||
```js
|
||||
assert.match(attack.toString(), /text\.innerText\s*\+=\s*('|") You attack it with your \1\s*\+\s*weapons\s*\[\s*currentWeapon\s*\]\s*\.name\s*\+\s*('|")\.\2/);
|
||||
|
||||
+2
-2
@@ -7,11 +7,11 @@ dashedName: step-127
|
||||
|
||||
# --description--
|
||||
|
||||
Inside the `dodge` function, set `text.innerText` equal to the string `You dodge the attack from the <monster>`. Replace `<monster>` with the name of the monster, using the `name` property.
|
||||
Inside the `dodge` function, set `text.innerText` equal to the string `"You dodge the attack from the <monster>"`. Replace `<monster>` with the name of the monster, using the `name` property.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should assign the string `You dodge the attack from the ` to the `text.innerText` property. Remember that spacing matters.
|
||||
You should assign the string `"You dodge the attack from the "` to the `text.innerText` property. Remember that spacing matters.
|
||||
|
||||
```js
|
||||
assert.match(dodge.toString(), /text\.innerText\s*=\s*('|")You dodge the attack from the \1/);
|
||||
|
||||
+5
-5
@@ -9,7 +9,7 @@ dashedName: step-132
|
||||
|
||||
Your `locations` array doesn't have a fifth element, so `locations[4]` doesn't work.
|
||||
|
||||
Add a new object at the end of the `locations` array, following the same structure as the other objects. Set `name` to `kill monster`, set `button text` to an array with three `Go to town square` strings, set `button functions` to an array with three `goTown` variables, and set `text` to `The monster screams Arg! as it dies. You gain experience points and find gold.`.
|
||||
Add a new object at the end of the `locations` array, following the same structure as the other objects. Set `name` to `"kill monster"`, set `"button text"` to an array with three `"Go to town square"` strings, set `"button functions"` to an array with three `goTown` variables, and set `text` to `"The monster screams Arg! as it dies. You gain experience points and find gold."`.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -25,25 +25,25 @@ Your fifth `locations` value should be an object.
|
||||
assert.isObject(locations[4]);
|
||||
```
|
||||
|
||||
Your fifth `locations` value should have a `name` property with the value `kill monster`.
|
||||
Your fifth `locations` value should have a `name` property with the value `"kill monster"`.
|
||||
|
||||
```js
|
||||
assert.equal(locations[4].name, 'kill monster');
|
||||
```
|
||||
|
||||
Your fifth `locations` value should have a `button text` array with three `Go to town square` strings.
|
||||
Your fifth `locations` value should have a `"button text"` array with three `"Go to town square"` strings.
|
||||
|
||||
```js
|
||||
assert.deepEqual(locations[4]["button text"], ['Go to town square', 'Go to town square', 'Go to town square']);
|
||||
```
|
||||
|
||||
Your fifth `locations` value should have a `button functions` array with three `goTown` variables.
|
||||
Your fifth `locations` value should have a `"button functions"` array with three `goTown` variables.
|
||||
|
||||
```js
|
||||
assert.deepEqual(locations[4]["button functions"], [goTown, goTown, goTown]);
|
||||
```
|
||||
|
||||
Your fifth `locations` value should have a `text` property with the value `The monster screams Arg! as it dies. You gain experience points and find gold.`.
|
||||
Your fifth `locations` value should have a `text` property with the value `"The monster screams Arg! as it dies. You gain experience points and find gold."`.
|
||||
|
||||
```js
|
||||
assert.equal(locations[4].text, 'The monster screams Arg! as it dies. You gain experience points and find gold.');
|
||||
|
||||
+3
-3
@@ -7,9 +7,9 @@ dashedName: step-133
|
||||
|
||||
# --description--
|
||||
|
||||
The word `Arg!` should have quotes around it. Besides escaping quotes, there is another way you can include quotation marks inside a string.
|
||||
The word `"Arg!"` should have quotes around it. Besides escaping quotes, there is another way you can include quotation marks inside a string.
|
||||
|
||||
Change the double quotes around the string `The monster screams Arg! as it dies. You gain experience points and find gold.` to single quotes `'`, then add double quotes around `Arg!`.
|
||||
Change the double quotes around the string `"The monster screams Arg! as it dies. You gain experience points and find gold."` to single quotes `'`, then add double quotes around `"Arg!"`.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -19,7 +19,7 @@ You should use single quotes around the string.
|
||||
assert.match(code, /'The monster screams "?Arg!"? as it dies. You gain experience points and find gold.'/);
|
||||
```
|
||||
|
||||
You should use double quotes around `Arg!`.
|
||||
You should use double quotes around `"Arg!"`.
|
||||
|
||||
```js
|
||||
assert.equal(locations[4].text, 'The monster screams "Arg!" as it dies. You gain experience points and find gold.');
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ Your `restart` function should set `currentWeapon` to `0`.
|
||||
assert.match(restart.toString(), /currentWeapon\s*=\s*0/);
|
||||
```
|
||||
|
||||
Your `restart` function should set `inventory` to an array with the string `stick`.
|
||||
Your `restart` function should set `inventory` to an array with the string `"stick"`.
|
||||
|
||||
```js
|
||||
assert.match(restart.toString(), /inventory\s*=\s*\[\s*('|")stick\1\s*\]/);
|
||||
|
||||
+4
-4
@@ -7,7 +7,7 @@ dashedName: step-141
|
||||
|
||||
# --description--
|
||||
|
||||
Add another object in the `locations` array. Everything should be the same as the `lose` object, except the `name` should be `win` and the `text` should be `You defeat the dragon! YOU WIN THE GAME! 🎉`.
|
||||
Add another object in the `locations` array. Everything should be the same as the `lose` object, except the `name` should be `"win"` and the `text` should be `"You defeat the dragon! YOU WIN THE GAME! 🎉"`.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -23,13 +23,13 @@ Your seventh `locations` value should be an object.
|
||||
assert.isObject(locations[6]);
|
||||
```
|
||||
|
||||
Your seventh `locations` value should have a `name` property with the value `win`.
|
||||
Your seventh `locations` value should have a `name` property with the value `"win"`.
|
||||
|
||||
```js
|
||||
assert.equal(locations[6].name, 'win');
|
||||
```
|
||||
|
||||
Your seventh `locations` value should have a `button text` array with three `REPLAY?` strings.
|
||||
Your seventh `locations` value should have a `button text` array with three `"REPLAY?"` strings.
|
||||
|
||||
```js
|
||||
assert.deepEqual(locations[6]["button text"], ['REPLAY?', 'REPLAY?', 'REPLAY?']);
|
||||
@@ -41,7 +41,7 @@ Your seventh `locations` value should have a `button functions` array with three
|
||||
assert.deepEqual(locations[6]["button functions"], [restart, restart, restart]);
|
||||
```
|
||||
|
||||
Your seventh `locations` value should have a `text` property with the value `You defeat the dragon! YOU WIN THE GAME! 🎉`.
|
||||
Your seventh `locations` value should have a `text` property with the value `"You defeat the dragon! YOU WIN THE GAME! 🎉"`.
|
||||
|
||||
```js
|
||||
assert.equal(locations[6].text, 'You defeat the dragon! YOU WIN THE GAME! 🎉');
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@ dashedName: step-150
|
||||
|
||||
# --description--
|
||||
|
||||
Add an `else` statement to the first `if` statement inside your `attack()` function. In the `else` statement, use the `+=` operator to add the text ` You miss.` to the end of `text.innerText`.
|
||||
Add an `else` statement to the first `if` statement inside your `attack()` function. In the `else` statement, use the `+=` operator to add the text `" You miss."` to the end of `text.innerText`.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -17,7 +17,7 @@ You should add an `else` block after your `if (isMonsterHit())` block.
|
||||
assert.match(attack.toString(), /if\s*\(\s*isMonsterHit\(\s*\)\s*\)\s*\{\s*monsterHealth\s*-=\s*weapons\s*\[\s*currentWeapon\s*\]\s*\.power\s*\+\s*Math\.floor\(\s*Math\.random\(\s*\)\s*\*\s*xp\s*\)\s*\+\s*1;\s*\}\s*else/)
|
||||
```
|
||||
|
||||
You should add the text ` You miss.` to the end of `text.innerText`. Remember to use compound assignment and make sure there is a space before the word `You`.
|
||||
You should add the text `" You miss."` to the end of `text.innerText`. Remember to use compound assignment and make sure there is a space before the word `You`.
|
||||
|
||||
```js
|
||||
assert.match(attack.toString(), /if\s*\(\s*isMonsterHit\(\s*\)\s*\)\s*\{\s*monsterHealth\s*-=\s*weapons\s*\[\s*currentWeapon\s*\]\s*\.power\s*\+\s*Math\.floor\(\s*Math\.random\(\s*\)\s*\*\s*xp\s*\)\s*\+\s*1;\s*\}\s*else\s*\{\s*text\.innerText\s*\+=\s*('|")\sYou miss\.\1/)
|
||||
|
||||
+3
-3
@@ -7,7 +7,7 @@ dashedName: step-154
|
||||
|
||||
# --description--
|
||||
|
||||
Use the `+=` operator to add `Your <weapon> breaks.`, with a space in front of `Your`, to the end of `text.innerText`. Replace `<weapon>` with the last item in the `inventory` array using `inventory.pop()`, which will remove the last item in the array AND return it so it appears in your string.
|
||||
Use the `+=` operator to add `" Your <weapon> breaks."`, with a space in front of `Your`, to the end of `text.innerText`. Replace `<weapon>` with the last item in the `inventory` array using `inventory.pop()`, which will remove the last item in the array AND return it so it appears in your string.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -30,13 +30,13 @@ You should add `Your`, with a space before and after it, to `text.innerText`.
|
||||
assert.match(attack.toString(), /text\.innerText\s*\+=\s*('|")\sYour\s\1/);
|
||||
```
|
||||
|
||||
You should add the return value of `inventory.pop()` to the ` Your ` string.
|
||||
You should add the return value of `inventory.pop()` to the `" Your "` string.
|
||||
|
||||
```js
|
||||
assert.match(attack.toString(), /text\.innerText\s*\+=\s*('|")\sYour\s\1\s*\+\s*inventory\.pop\(\s*\)/);
|
||||
```
|
||||
|
||||
You should add `breaks.`, with a space in front of it, to the end of your string.
|
||||
You should add `" breaks."`, with a space in front of it, to the end of your string.
|
||||
|
||||
```js
|
||||
assert.match(attack.toString(), /text\.innerText\s*\+=\s*('|")\sYour\s\1\s*\+\s*inventory\.pop\(\s*\)\s*\+\s*('|")\sbreaks\.\2/);
|
||||
|
||||
+5
-5
@@ -7,7 +7,7 @@ dashedName: step-160
|
||||
|
||||
# --description--
|
||||
|
||||
Add another object to your `locations` array. Set `name` to `easter egg`, set `button text` to an array with the strings `2`, `8`, and `Go to town square?`, set `button functions` to an array with the variables `pickTwo`, `pickEight`, and `goTown`, and `text` to `You find a secret game. Pick a number above. Ten numbers will be randomly chosen between 0 and 10. If the number you choose matches one of the random numbers, you win!`.
|
||||
Add another object to your `locations` array. Set `name` to `"easter egg"`, set `"button text"` to an array with the strings `"2"`, `"8"`, and `"Go to town square?"`, set `"button functions"` to an array with the variables `pickTwo`, `pickEight`, and `goTown`, and `text` to `"You find a secret game. Pick a number above. Ten numbers will be randomly chosen between 0 and 10. If the number you choose matches one of the random numbers, you win!"`.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -23,25 +23,25 @@ Your eighth `locations` value should be an object.
|
||||
assert.isObject(locations[7]);
|
||||
```
|
||||
|
||||
Your eighth `locations` value should have a `name` property with the value `easter egg`.
|
||||
Your eighth `locations` value should have a `name` property with the value `"easter egg"`.
|
||||
|
||||
```js
|
||||
assert.equal(locations[7].name, "easter egg");
|
||||
```
|
||||
|
||||
Your eighth `locations` value should have a `button text` array with the strings `2`, `8`, and `Go to town square?`.
|
||||
Your eighth `locations` value should have a `"button text"` array with the strings `"2"`, `"8"`, and `"Go to town square?"`.
|
||||
|
||||
```js
|
||||
assert.deepEqual(locations[7]["button text"], ["2", "8", "Go to town square?"]);
|
||||
```
|
||||
|
||||
Your eighth `locations` value should have a `button functions` an array with the variables `pickTwo`, `pickEight`, and `goTown`.
|
||||
Your eighth `locations` value should have a `"button functions"` an array with the variables `pickTwo`, `pickEight`, and `goTown`.
|
||||
|
||||
```js
|
||||
assert.deepEqual(locations[7]["button functions"], [pickTwo, pickEight, goTown]);
|
||||
```
|
||||
|
||||
Your eighth `locations` value should have a `text` property with the value `You find a secret game. Pick a number above. Ten numbers will be randomly chosen between 0 and 10. If the number you choose matches one of the random numbers, you win!`.
|
||||
Your eighth `locations` value should have a `text` property with the value `"You find a secret game. Pick a number above. Ten numbers will be randomly chosen between 0 and 10. If the number you choose matches one of the random numbers, you win!"`.
|
||||
|
||||
```js
|
||||
assert.equal(locations[7].text, "You find a secret game. Pick a number above. Ten numbers will be randomly chosen between 0 and 10. If the number you choose matches one of the random numbers, you win!");
|
||||
|
||||
+4
-4
@@ -7,23 +7,23 @@ dashedName: step-164
|
||||
|
||||
# --description--
|
||||
|
||||
After the `while` loop, set `text.innerText` to equal `You picked <someGuess>. Here are the random numbers:`. Replace `<someGuess>` with the `guess` function parameter.
|
||||
After the `while` loop, set `text.innerText` to equal `"You picked <someGuess>. Here are the random numbers:"`. Replace `<someGuess>` with the `guess` function parameter.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should set `text.innerText` to the string `You picked `. Remember that spacing matters.
|
||||
You should set `text.innerText` to the string `"You picked "`. Remember that spacing matters.
|
||||
|
||||
```js
|
||||
assert.match(pick.toString(), /text\.innerText\s*=\s*('|")You picked \1/);
|
||||
```
|
||||
|
||||
You should use the concatenation operator to add the value of the `guess` parameter to your `You picked ` string.
|
||||
You should use the concatenation operator to add the value of the `guess` parameter to your `"You picked "` string.
|
||||
|
||||
```js
|
||||
assert.match(pick.toString(), /text\.innerText\s*=\s*('|")You picked \1\s*\+\s*guess/);
|
||||
```
|
||||
|
||||
You should use the concatenation operator to add the string `. Here are the random numbers:` to your `"You picked " + guess` string.
|
||||
You should use the concatenation operator to add the string `". Here are the random numbers:"` to your `"You picked " + guess` string.
|
||||
|
||||
```js
|
||||
assert.match(pick.toString(), /text\.innerText\s*=\s*('|")You picked \1\s*\+\s*guess\s*\+\s*('|")\.\sHere are the random numbers:\2/);
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ At the end of the string, before the final quote, insert the new line escape cha
|
||||
|
||||
# --hints--
|
||||
|
||||
You should add the new line escape character `\n` to your `. Here are the random numbers: ` string.
|
||||
You should add the new line escape character `\n` to your `". Here are the random numbers: "` string.
|
||||
|
||||
```js
|
||||
assert.match(pick.toString(), /text\.innerText\s*=\s*('|")You picked \1\s*\+\s*guess\s*\+\s*('|")\.\sHere are the random numbers:\\n\2/);
|
||||
|
||||
+2
-2
@@ -7,11 +7,11 @@ dashedName: step-172
|
||||
|
||||
# --description--
|
||||
|
||||
Inside the `if` statement, add the string `Right! You win 20 gold!` to the end of `text.innerText`. Also, add `20` to the value of `gold` and update the `goldText.innerText`.
|
||||
Inside the `if` statement, add the string `"Right! You win 20 gold!"` to the end of `text.innerText`. Also, add `20` to the value of `gold` and update the `goldText.innerText`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should use compound assignment to add the string `Right! You win 20 gold!` to the end of `text.innerText`.
|
||||
You should use compound assignment to add the string `"Right! You win 20 gold!"` to the end of `text.innerText`.
|
||||
|
||||
```js
|
||||
assert.match(pick.toString(), /text\.innerText\s*\+=\s*('|")Right! You win 20 gold!\1/);
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@ dashedName: step-173
|
||||
|
||||
# --description--
|
||||
|
||||
Now add an `else` statement. Inside, add `Wrong! You lose 10 health!` to the end of `text.innerText`. Subtract `10` from `health` and update `healthText.innerText`.
|
||||
Now add an `else` statement. Inside, add `"Wrong! You lose 10 health!"` to the end of `text.innerText`. Subtract `10` from `health` and update `healthText.innerText`.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -17,7 +17,7 @@ You should add an `else` block.
|
||||
assert.match(pick.toString(), /else\s*\{/);
|
||||
```
|
||||
|
||||
Your `else` block should use compound assignment to add `Wrong! You lose 10 health!` to the end of `text.innerText`.
|
||||
Your `else` block should use compound assignment to add `"Wrong! You lose 10 health!"` to the end of `text.innerText`.
|
||||
|
||||
```js
|
||||
assert.match(pick.toString(), /text\.innerText\s*\+=\s*('|")Wrong! You lose 10 health!\1/);
|
||||
|
||||
+2
-2
@@ -7,13 +7,13 @@ dashedName: step-175
|
||||
|
||||
# --description--
|
||||
|
||||
Looking at your `kill monster` object, `button functions` currently has three `goTown` variables. Replace the third one with `easterEgg` - this is how a player will access the hidden feature of the game. Do not change the `button text`.
|
||||
Looking at your `"kill monster"` object, `"button functions"` currently has three `goTown` variables. Replace the third one with `easterEgg` - this is how a player will access the hidden feature of the game. Do not change the `"button text"`.
|
||||
|
||||
With this, your RPG game is complete! You can now play around - can you defeat the dragon?
|
||||
|
||||
# --hints--
|
||||
|
||||
You should update your fifth `locations` object to have a `button functions` property of `[goTown, goTown, easterEgg]`.
|
||||
You should update your fifth `locations` object to have a `"button functions"` property of `[goTown, goTown, easterEgg]`.
|
||||
|
||||
```js
|
||||
assert.deepEqual(locations[4]["button functions"], [goTown, goTown, easterEgg]);
|
||||
|
||||
+5
-5
@@ -7,7 +7,7 @@ dashedName: step-137
|
||||
|
||||
# --description--
|
||||
|
||||
In the `locations` array, add another object at the end. Set the `name` property to `lose`, set `button text` to an array with three `REPLAY?` strings, set `button functions` to an array with three `restart` variables, and set `text` to `You die. ☠`.
|
||||
In the `locations` array, add another object at the end. Set the `name` property to `"lose"`, set `"button text"` to an array with three `"REPLAY?"` strings, set `"button functions"` to an array with three `restart` variables, and set `text` to `"You die. ☠"`.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -23,25 +23,25 @@ Your sixth `locations` value should be an object.
|
||||
assert.isObject(locations[5]);
|
||||
```
|
||||
|
||||
Your sixth `locations` value should have a `name` property with the value `lose`.
|
||||
Your sixth `locations` value should have a `name` property with the value `"lose"`.
|
||||
|
||||
```js
|
||||
assert.equal(locations[5].name, 'lose');
|
||||
```
|
||||
|
||||
Your sixth `locations` value should have a `button text` array with three `REPLAY?` strings.
|
||||
Your sixth `locations` value should have a `"button text"` array with three `"REPLAY?"` strings.
|
||||
|
||||
```js
|
||||
assert.deepEqual(locations[5]["button text"], ['REPLAY?', 'REPLAY?', 'REPLAY?']);
|
||||
```
|
||||
|
||||
Your sixth `locations` value should have a `button functions` array with three `restart` variables.
|
||||
Your sixth `locations` value should have a `"button functions"` array with three `restart` variables.
|
||||
|
||||
```js
|
||||
assert.deepEqual(locations[5]["button functions"], [restart, restart, restart]);
|
||||
```
|
||||
|
||||
Your sixth `locations` value should have a `text` property with the value `You die. ☠`.
|
||||
Your sixth `locations` value should have a `text` property with the value `"You die. ☠"`.
|
||||
|
||||
```js
|
||||
assert.equal(locations[5].text, 'You die. ☠');
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@ You should declare a `button2` variable with `const`.
|
||||
assert.match(code, /const\s+button2/);
|
||||
```
|
||||
|
||||
Your `button2` variable should have the value of your `#button2` element.
|
||||
Your `button2` variable should have the value of your `"#button2"` element.
|
||||
|
||||
```js
|
||||
assert.deepEqual(button2, document.querySelector('#button2'));
|
||||
@@ -29,7 +29,7 @@ You should declare a `button3` variable with `const`.
|
||||
assert.match(code, /const\s+button3/);
|
||||
```
|
||||
|
||||
Your `button3` variable should have the value of your `#button3` element.
|
||||
Your `button3` variable should have the value of your `"#button3"` element.
|
||||
|
||||
```js
|
||||
assert.deepEqual(button3, document.querySelector('#button3'));
|
||||
|
||||
Reference in New Issue
Block a user