From f90905fbfe1f8a6ae2a968dffaef55a536382bd8 Mon Sep 17 00:00:00 2001 From: bengguankoay <118246443+bengguankoay@users.noreply.github.com> Date: Fri, 21 Nov 2025 03:26:07 +0800 Subject: [PATCH] fix(curriculum): improve getResults test to prevent TypeError in lab-quiz-game (#63993) Co-authored-by: beng guan koay --- .../lab-quiz-game/66f17db06803d11a1bd19a20.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/curriculum/challenges/english/blocks/lab-quiz-game/66f17db06803d11a1bd19a20.md b/curriculum/challenges/english/blocks/lab-quiz-game/66f17db06803d11a1bd19a20.md index 07f55a11ba7..dd8b671fde4 100644 --- a/curriculum/challenges/english/blocks/lab-quiz-game/66f17db06803d11a1bd19a20.md +++ b/curriculum/challenges/english/blocks/lab-quiz-game/66f17db06803d11a1bd19a20.md @@ -111,8 +111,10 @@ assert.isFunction(getResults); Your `getResults` function should take the question object as the first parameter and the computer's choice as the second parameter. ```js -assert.equal(getResults(questions[0], questions[0].answer), `The computer's choice is correct!`); -assert.notEqual(getResults(questions[0].answer, questions[0]), `The computer's choice is correct!`); +const testQuestion = questions[0]; +const wrongChoice = questions[0].choices.find(choice => choice !== questions[0].answer); +assert.equal(getResults(testQuestion, testQuestion.answer), `The computer's choice is correct!`); +assert.equal(getResults(testQuestion, wrongChoice), `The computer's choice is wrong. The correct answer is: ${testQuestion.answer}`); ``` If the computer choice matches the answer, `getResults` should return `The computer's choice is correct!` @@ -127,6 +129,13 @@ If the computer choice doesn't match the answer, `getResults` should return `The assert.equal(getResults({category: 'misc', choices: ['a', 'b', 'c'], question: "question?", answer: "b"}, "a"), `The computer's choice is wrong. The correct answer is: b`) ``` +Your `getResults` function should use exact equality comparison, not substring matching. + +```js +assert.equal(getResults({category: 'food', choices: ['Ham', 'Hamburger', 'Hot Dog'], question: "What food?", answer: "Hamburger"}, "Ham"), `The computer's choice is wrong. The correct answer is: Hamburger`); +assert.equal(getResults({category: 'food', choices: ['Ham', 'Hamburger', 'Hot Dog'], question: "What food?", answer: "Ham"}, "Hamburger"), `The computer's choice is wrong. The correct answer is: Ham`); +``` + # --seed-- ## --seed-contents--