fix(curriculum): update quiz game lab (#58902)

This commit is contained in:
Josue Igiraneza
2025-02-24 16:41:11 +02:00
committed by GitHub
parent 63afbf4c7c
commit 4a9f226b15
@@ -17,7 +17,7 @@ Fulfill the user stories below and get all the tests to pass to complete the lab
1. The `question` key should have the value of a string representing a question.
1. The `choices` key should have the value of an array containing three strings, which are alternative answers to the question.
1. The `answer` key should have the value of a string, representing the correct answer to the question. Also, the value of `answer` should be included in the `choices` array.
1. You should have a function named `getRandomQuestion` that takes the `questions` array and returns a random question object from the array.
1. You should have a function named `getRandomQuestion` that takes an array of questions as a parameter and returns a random question object from the array.
1. You should have a function named `getRandomComputerChoice` that takes the array of the available choices as a parameter, and returns a random answer to the selected question.
1. You should have a function named `getResults` that takes the selected question object and the computer choice as its parameters and returns `The computer's choice is correct!` if the answer is correct. Otherwise, it returns `The computer's choice is wrong. The correct answer is: <correct-answer>`, where `<correct-answer>` is the value of the correct answer to the chosen question.
@@ -82,13 +82,14 @@ assert.isNotEmpty(questions);
questions.forEach(({answer, choices}) => assert.oneOf(answer, choices));
```
You should have a function named `getRandomQuestion` that takes the `questions` array and returns a random question object from the array.
You should have a function named `getRandomQuestion` that takes an array of questions as a parameter and returns a random question object from the array.
```js
const parameters = __helpers.getFunctionParams(getRandomQuestion.toString());
assert.isFunction(getRandomQuestion);
assert.lengthOf(parameters, 1);
assert.lengthOf(getRandomQuestion, 1);
assert.isObject(getRandomQuestion(questions));
assert.deepInclude(questions, getRandomQuestion(questions), "getRandomQuestion did not return one of the objects inside questions");
```