mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-09-24 23:01:18 +08:00
fix(curriculum) : dice game 84 and 85 restore small straights (#54138)
Co-authored-by: Jessica Wilkins <67210629+jdwilkin4@users.noreply.github.com>
This commit is contained in:
+3
-3
@@ -345,11 +345,11 @@
|
||||
"title": "Step 83"
|
||||
},
|
||||
{
|
||||
"id": "657e2ecee9f60092c89338d9",
|
||||
"id": "657e30e116d50c946b189925",
|
||||
"title": "Step 84"
|
||||
},
|
||||
{
|
||||
"id": "657e30e116d50c946b189925",
|
||||
"id": "657e2ecee9f60092c89338d9",
|
||||
"title": "Step 85"
|
||||
},
|
||||
{
|
||||
@@ -362,4 +362,4 @@
|
||||
}
|
||||
],
|
||||
"helpCategory": "JavaScript"
|
||||
}
|
||||
}
|
||||
|
||||
+18
-8
@@ -1,28 +1,33 @@
|
||||
---
|
||||
id: 657e2ecee9f60092c89338d9
|
||||
title: Step 84
|
||||
title: Step 85
|
||||
challengeType: 0
|
||||
dashedName: step-84
|
||||
dashedName: step-85
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
If the user rolls a small straight, then the `Small straight` radio button option should be enabled with a score of `30` points.
|
||||
If the user rolls a small straight, then the `Small straight` radio button option should be enabled with a score of `30` points. A small straight consists of four separate dice rolls arranged in numerical order.
|
||||
|
||||
Start by creating an `if` statement to check if `uniqueNumbersStr` is included in the `smallStraightsArr`. If so, call the `updateRadioOption` with `3` and `30` for the arguments.
|
||||
To get started, iterate through `smallStraightsArr` using any loop you prefer. If using a higher-order function like `forEach` or `some`, the callback function should take an argument of `straight`. If using `for...of`, the loop variable should also be `straight`.
|
||||
|
||||
Inside the loop, if `uniqueNumbersStr` has a combination that matches a small straight, call the `updateRadioOption` with `3` and `30` as the arguments.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should use the `includes` method to check if `uniqueNumbersStr` is included in the `smallStraightsArr`.
|
||||
You should use the `includes` method to check if `straight` is included in the `uniqueNumbersStr`.
|
||||
|
||||
```js
|
||||
assert.match(code, /if\s*\(\s*smallStraightsArr\.includes\(\s*uniqueNumbersStr\s*\)\s*\)\s*{?/);
|
||||
assert.match(code, /\s*i?f?\(?\s*uniqueNumbersStr\.includes\(\s*(straight|smallStraightsArr\[i\])\s*\)\)\s*\)?\s*\{/)
|
||||
```
|
||||
|
||||
You should call your `updateRadioOption` with `3` and `30` for the arguments.
|
||||
|
||||
```js
|
||||
assert.match(code, /if\s*\(\s*smallStraightsArr\.includes\(\s*uniqueNumbersStr\s*\)\s*\)\s*{?\s*updateRadioOption\s*\(\s*3\s*,\s*30\s*\)\s*;?\s*}?/);
|
||||
checkForStraights(["1","2","3","4","6"]);
|
||||
assert.isFalse(scoreInputs[3].disabled);
|
||||
assert.equal(scoreInputs[3].value,30);
|
||||
assert.equal(scoreSpans[3].textContent,', score = 30');
|
||||
```
|
||||
|
||||
# --seed--
|
||||
@@ -374,10 +379,15 @@ const checkForStraights = (arr) => {
|
||||
|
||||
const smallStraightsArr = ["1234", "2345", "3456"];
|
||||
const largeStraightsArr = ["12345", "23456"];
|
||||
--fcc-editable-region--
|
||||
|
||||
|
||||
--fcc-editable-region--
|
||||
|
||||
--fcc-editable-region--
|
||||
if (largeStraightsArr.includes(uniqueNumbersStr)) {
|
||||
updateRadioOption(4, 40);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
const resetRadioOption = () => {
|
||||
|
||||
+3
-7
@@ -1,8 +1,8 @@
|
||||
---
|
||||
id: 657e30e116d50c946b189925
|
||||
title: Step 85
|
||||
title: Step 84
|
||||
challengeType: 0
|
||||
dashedName: step-85
|
||||
dashedName: step-84
|
||||
---
|
||||
|
||||
# --description--
|
||||
@@ -374,11 +374,7 @@ const checkForStraights = (arr) => {
|
||||
|
||||
const smallStraightsArr = ["1234", "2345", "3456"];
|
||||
const largeStraightsArr = ["12345", "23456"];
|
||||
|
||||
if (smallStraightsArr.includes(uniqueNumbersStr)) {
|
||||
updateRadioOption(3, 30);
|
||||
}
|
||||
|
||||
|
||||
--fcc-editable-region--
|
||||
|
||||
--fcc-editable-region--
|
||||
|
||||
+1
-1
@@ -367,7 +367,7 @@ const checkForStraights = (arr) => {
|
||||
const smallStraightsArr = ["1234", "2345", "3456"];
|
||||
const largeStraightsArr = ["12345", "23456"];
|
||||
|
||||
if (smallStraightsArr.includes(uniqueNumbersStr)) {
|
||||
if (smallStraightsArr.some(straight => uniqueNumbersStr.includes(straight))) {
|
||||
updateRadioOption(3, 30);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -369,7 +369,7 @@ const checkForStraights = (arr) => {
|
||||
const smallStraightsArr = ["1234", "2345", "3456"];
|
||||
const largeStraightsArr = ["12345", "23456"];
|
||||
|
||||
if (smallStraightsArr.includes(uniqueNumbersStr)) {
|
||||
if (smallStraightsArr.some(straight => uniqueNumbersStr.includes(straight))) {
|
||||
updateRadioOption(3, 30);
|
||||
}
|
||||
|
||||
@@ -817,7 +817,7 @@ const checkForStraights = (arr) => {
|
||||
const smallStraightsArr = ["1234", "2345", "3456"];
|
||||
const largeStraightsArr = ["12345", "23456"];
|
||||
|
||||
if (smallStraightsArr.includes(uniqueNumbersStr)) {
|
||||
if (smallStraightsArr.some(straight => uniqueNumbersStr.includes(straight))) {
|
||||
updateRadioOption(3, 30);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user