Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions exercises/concept/high-score-board/.docs/hints.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
23 changes: 0 additions & 23 deletions exercises/concept/high-score-board/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
10 changes: 0 additions & 10 deletions exercises/concept/high-score-board/.meta/exemplar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
25 changes: 0 additions & 25 deletions exercises/concept/high-score-board/high-score-board.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
addPlayer,
applyMondayBonus,
createScoreBoard,
normalizeScore,
removePlayer,
updateScore,
} from './high-score-board';
Expand Down Expand Up @@ -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);
});
});