fix(curriculum): correct if...else to be statements (#52899)

This commit is contained in:
Lasse Jørgensen
2024-01-03 04:38:38 +01:00
committed by GitHub
parent 0d123e0ba9
commit 883d09fddd
5 changed files with 7 additions and 7 deletions

View File

@@ -7,9 +7,9 @@ dashedName: step-140
# --description--
JavaScript has a conditional operator called the <dfn>ternary operator</dfn>. This can be used as a one-line `if-else` expression. The syntax is: `condition ? true : false`.
JavaScript has a conditional operator called the <dfn>ternary operator</dfn>. This can be used as a one-line `if-else` statement. The syntax is: `condition ? true : false`.
Here is an example of an `if-else` expression changed to a ternary:
Here is an example of an `if-else` statement changed to a ternary:
```js
if (num > 5) {
@@ -21,7 +21,7 @@ if (num > 5) {
num > 5 ? bigger() : smaller();
```
Change your new `if-else` expression to a ternary.
Change your new `if-else` statement to a ternary.
# --hints--

View File

@@ -7,7 +7,7 @@ dashedName: step-154
# --description--
On every attack, there should be a chance that the player's weapon breaks. At the end of the `attack` function, add an empty `if` expression with the condition `Math.random() <= .1`.
On every attack, there should be a chance that the player's weapon breaks. At the end of the `attack` function, add an empty `if` statement with the condition `Math.random() <= .1`.
# --hints--

View File

@@ -9,7 +9,7 @@ dashedName: step-172
The `indexOf()` array method returns the first index at which a given element can be found in the array, or `-1` if the element is not present.
After your `for` loop, add an `if` expression to check if the `guess` is in the `numbers` array. You can check if `indexOf` is not equal (`!==`) to `-1`.
After your `for` loop, add an `if` statement to check if the `guess` is in the `numbers` array. You can check if `indexOf` is not equal (`!==`) to `-1`.
Here is an example of the `indexOf` syntax:

View File

@@ -7,7 +7,7 @@ dashedName: step-173
# --description--
Inside the `if` expression, 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--

View File

@@ -7,7 +7,7 @@ dashedName: step-174
# --description--
Now add an `else` expression. 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--