mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-04-15 10:00:47 -04:00
fix(curriculum): correct if...else to be statements (#52899)
This commit is contained in:
@@ -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--
|
||||
|
||||
|
||||
@@ -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--
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
|
||||
@@ -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--
|
||||
|
||||
|
||||
@@ -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--
|
||||
|
||||
|
||||
Reference in New Issue
Block a user