From 85bdeb1ea70c2e21660677b13334c25f5a42ac62 Mon Sep 17 00:00:00 2001 From: Derk-Jan Karrenbeld Date: Sun, 15 Jun 2025 14:43:44 +0200 Subject: [PATCH] Simplify objects concept --- .../concept/high-score-board/.docs/hints.md | 5 ---- .../high-score-board/.docs/instructions.md | 23 ----------------- .../high-score-board/.meta/exemplar.js | 10 -------- .../high-score-board/high-score-board.spec.js | 25 ------------------- 4 files changed, 63 deletions(-) diff --git a/exercises/concept/high-score-board/.docs/hints.md b/exercises/concept/high-score-board/.docs/hints.md index f38a74fb6a..439fd9d8d2 100644 --- a/exercises/concept/high-score-board/.docs/hints.md +++ b/exercises/concept/high-score-board/.docs/hints.md @@ -28,11 +28,6 @@ - Use a `for...in` loop to go through all keys in the object. - For each key, set the new value as you did in task 4. -## 6. Normalize a high score - -- You can access the normalization function like you would access any other key in the object. -- Then, you can call that function using round brackets and pass in the score as an argument. - [mdn-delete]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/delete [mdn-shorthand-assignment]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Addition_assignment [mdn-for-in]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in diff --git a/exercises/concept/high-score-board/.docs/instructions.md b/exercises/concept/high-score-board/.docs/instructions.md index 6e04979ccd..ea7118dfdb 100644 --- a/exercises/concept/high-score-board/.docs/instructions.md +++ b/exercises/concept/high-score-board/.docs/instructions.md @@ -87,26 +87,3 @@ const scoreBoard = { applyMondayBonus(scoreBoard); // => { 'Dave Thomas': 144, 'Freyja Ćirić': 639, 'José Valim': 365 } ``` - -## 6. Normalize a high score - -Different arcade halls award different score points. -To celebrate the best arcade player in town, a player's score needs to be normalized so scores from different arcade halls become comparable. - -Write a function `normalizeScore`. -To practice your object skills, instead of two parameters this function should accept one object as a parameter. -That object contains a key `score` with the value being a player's score (a number). -There is also a second key `normalizeFunction` that has a function as its value. -This function takes a score as an argument and returns the corrected score. - -Your function `normalizeScore` should return the normalized score that you get after applying the normalization function to the score that was passed in. - -```javascript -function normalize(score) { - return 2 * score + 10; -} - -const params = { score: 400, normalizeFunction: normalize }; -normalizeScore(params); -// => 810 -``` diff --git a/exercises/concept/high-score-board/.meta/exemplar.js b/exercises/concept/high-score-board/.meta/exemplar.js index c0bc95507f..5db3ee8616 100644 --- a/exercises/concept/high-score-board/.meta/exemplar.js +++ b/exercises/concept/high-score-board/.meta/exemplar.js @@ -63,13 +63,3 @@ export function applyMondayBonus(scoreBoard) { return scoreBoard; } - -/** - * Normalizes a score with the provided normalization function. - * - * @param {Params} params the parameters for performing the normalization - * @returns {number} normalized score - */ -export function normalizeScore(params) { - return params.normalizeFunction(params.score); -} diff --git a/exercises/concept/high-score-board/high-score-board.spec.js b/exercises/concept/high-score-board/high-score-board.spec.js index d279d882f9..42f5f67823 100644 --- a/exercises/concept/high-score-board/high-score-board.spec.js +++ b/exercises/concept/high-score-board/high-score-board.spec.js @@ -3,7 +3,6 @@ import { addPlayer, applyMondayBonus, createScoreBoard, - normalizeScore, removePlayer, updateScore, } from './high-score-board'; @@ -130,27 +129,3 @@ describe('applyMondayBonus', () => { expect(Object.is(actual, scoreBoard)).toBe(true); }); }); - -describe('normalizeScore', () => { - test('applies the normalization function', () => { - const params = { - score: 45, - normalizeFunction: function (score) { - return score * 3 - 10; - }, - }; - - expect(normalizeScore(params)).toEqual(125); - }); - - test('works for different params', () => { - const params = { - score: 2100, - normalizeFunction: function (score) { - return score / 2 + 100; - }, - }; - - expect(normalizeScore(params)).toEqual(1150); - }); -});