From 87cf2f26330299a8f5ab78023ba498a764e425cb Mon Sep 17 00:00:00 2001 From: Aditya Singh Date: Thu, 8 Jan 2026 14:13:52 +0530 Subject: [PATCH] fix(curriculum): add test for clarifying output formatting in lab voting system (#65017) --- .../673b567e3ba535dda140d278.md | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/curriculum/challenges/english/blocks/lab-voting-system/673b567e3ba535dda140d278.md b/curriculum/challenges/english/blocks/lab-voting-system/673b567e3ba535dda140d278.md index e607d647544..429285bd91a 100644 --- a/curriculum/challenges/english/blocks/lab-voting-system/673b567e3ba535dda140d278.md +++ b/curriculum/challenges/english/blocks/lab-voting-system/673b567e3ba535dda140d278.md @@ -276,6 +276,32 @@ try { } ``` +When option `Turkey` gets two votes, option `Morocco` gets one vote, and option `Spain` doesn't get any vote, `displayResults()` should return `"Poll Results:\nTurkey: 2 votes\nMorocco: 1 votes\nSpain: 0 votes"`. + +```js +const pollCopy = new Map(poll); +try { + poll.clear(); + addOption('Turkey'); + addOption('Morocco'); + addOption('Spain'); + + vote('Turkey', 'traveler1'); + vote('Turkey', 'traveler2'); + vote('Morocco', 'traveler3'); + + assert.equal( + displayResults(), + 'Poll Results:\nTurkey: 2 votes\nMorocco: 1 votes\nSpain: 0 votes' + ); +} finally { + poll.clear(); + pollCopy.forEach((val, key) => { + poll.set(key, val); + }); +} +``` + `displayResults()` should return the results in the correct format. ```js