fix(curriculum): small fixes in JS RPG project (#57146)

Co-authored-by: Huyen Nguyen <25715018+huyenltnguyen@users.noreply.github.com>
This commit is contained in:
yoko
2024-11-15 16:53:17 +09:00
committed by GitHub
parent 9f3e827e37
commit f37291880e
10 changed files with 13 additions and 13 deletions

View File

@@ -18,7 +18,7 @@ const info = document.querySelector("#info");
info.innerText = "Hello World";
```
The following example would change the text of the `p` element from `Demo content` to `Hello World`.
The example above would change the text of the `p` element from `Demo content` to `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)"`.

View File

@@ -7,9 +7,9 @@ dashedName: step-54
# --description--
Your locations `array` will hold different locations like the **store**, the **cave**, and the **town square**. Each location will be represented as an object.
Your `locations` array will hold different locations like the **store**, the **cave**, and the **town square**. Each location will be represented as an object.
Inside your locations array, add an object. Inside that object add a key called `name` with a value of `"town square"`.
Inside your `locations` array, add an object. Inside that object add a key called `name` with a value of `"town square"`.
Remember to follow this syntax:

View File

@@ -7,7 +7,7 @@ dashedName: step-99
# --description--
If the player has purchased all of the weapons in the inventory, the player should not be able to purchase any more and a message should be displayed.
If the player has purchased all of the weapons in the `weapons` array, the player should not be able to purchase any more and a message should be displayed.
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!"`.

View File

@@ -17,7 +17,7 @@ You should use bracket notation to access the `monsters` array at the `fighting`
assert.match(goFight.toString(), /monsters\s*\[\s*fighting\s*\]/);
```
You should assign the value of `monsters[fighting]` to the `monsterHealth` variable.
You should assign the value of the `health` property of `monsters[fighting]` to the `monsterHealth` variable.
```js
assert.match(goFight.toString(), /monsterHealth\s*=\s*monsters\s*\[\s*fighting\s*\]\s*(\.health|\[\s*('|")health\2\s*\])/);

View File

@@ -17,19 +17,19 @@ You should use dot notation to access the `innerText` property of `text`.
assert.match(attack.toString(), /text\.innerText/);
```
You should assign the string `The ` to `innerText` property of `text`.
You should assign the string `"The "` to `innerText` property of `text`.
```js
assert.match(attack.toString(), /text\.innerText\s*=\s*('|")The \1/);
```
You should use the concatenation operator to add the value of `monsters[fighting].name` to the `The ` string.
You should use the concatenation operator to add the value of `monsters[fighting].name` to the string `"The "`.
```js
assert.match(attack.toString(), /text\.innerText\s*=\s*('|")The \1\s*\+\s*monsters\s*\[\s*fighting\s*\]\s*\.name/);
```
You should use the concatenation operator to add the string ` attacks.` to the `monsters[fighting].name` string.
You should use the concatenation operator to add the string `" attacks."` to the `monsters[fighting].name` string.
```js
assert.match(attack.toString(), /text\.innerText\s*=\s*('|")The \1\s*\+\s*monsters\s*\[\s*fighting\s*\]\s*\.name\s*\+\s*('|") attacks\.\2/);

View File

@@ -7,7 +7,7 @@ dashedName: step-150
# --description--
In your attack function, find the line of code that updates the `monsterHealth` variable and place it within an `if` block with a condition that calls the `isMonsterHit` function.
In your `attack` function, find the line of code that updates the `monsterHealth` variable and place it within an `if` block with a condition that calls the `isMonsterHit` function.
# --hints--

View File

@@ -24,7 +24,7 @@ You should use the `pop` method on the `inventory` array.
assert.match(attack.toString(), /inventory\.pop\(\s*\)/);
```
You should add `Your`, with a space before and after it, to `text.innerText`.
You should add `" Your "`, with a space before and after it, to `text.innerText`.
```js
assert.match(attack.toString(), /text\.innerText\s*\+=\s*('|")\sYour\s\1/);

View File

@@ -21,7 +21,7 @@ if (firstName === "Quincy" && lastName === "Larson") {
# --hints--
You should not modify your existing `if` statement.
You should not modify the existing condition in your `if` statement.
```js
assert.match(attack.toString(), /if\s*\(\s*Math\.random\(\s*\)\s*\<=\s*\.1/);

View File

@@ -31,7 +31,7 @@ const split = code.split(/text\.innerText\s*\+=\s*numbers/)?.[1]?.split(/\}/)?.[
assert.match(split, /if/);
```
Inside your `if` statement, check if the `guess` is in the numbers array using the `.includes()` method.
Inside your `if` statement, check if the `guess` is in the `numbers` array using the `.includes()` method.
```js
const split = code.split(/text\.innerText\s*\+=\s*numbers/)?.[1]?.split(/\}/)?.[1];

View File

@@ -7,7 +7,7 @@ dashedName: step-49
# --description--
Objects are similar to `arrays`, except that instead of using indexes to access and modify their data, you access the data in objects through `properties`.
Objects are similar to arrays, except that instead of using indexes to access and modify their data, you access the data in objects through properties.
Properties consist of a key and a value. The key is the name of the property, and the value is the data stored in the property.