Skip to content

Commit 00b22c8

Browse files
Simplify objects concept (#2679)
[no important files changed]
1 parent 2419d45 commit 00b22c8

File tree

4 files changed

+0
-63
lines changed

4 files changed

+0
-63
lines changed

exercises/concept/high-score-board/.docs/hints.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@
2828
- Use a `for...in` loop to go through all keys in the object.
2929
- For each key, set the new value as you did in task 4.
3030

31-
## 6. Normalize a high score
32-
33-
- You can access the normalization function like you would access any other key in the object.
34-
- Then, you can call that function using round brackets and pass in the score as an argument.
35-
3631
[mdn-delete]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/delete
3732
[mdn-shorthand-assignment]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Addition_assignment
3833
[mdn-for-in]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in

exercises/concept/high-score-board/.docs/instructions.md

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -87,26 +87,3 @@ const scoreBoard = {
8787
applyMondayBonus(scoreBoard);
8888
// => { 'Dave Thomas': 144, 'Freyja Ćirić': 639, 'José Valim': 365 }
8989
```
90-
91-
## 6. Normalize a high score
92-
93-
Different arcade halls award different score points.
94-
To celebrate the best arcade player in town, a player's score needs to be normalized so scores from different arcade halls become comparable.
95-
96-
Write a function `normalizeScore`.
97-
To practice your object skills, instead of two parameters this function should accept one object as a parameter.
98-
That object contains a key `score` with the value being a player's score (a number).
99-
There is also a second key `normalizeFunction` that has a function as its value.
100-
This function takes a score as an argument and returns the corrected score.
101-
102-
Your function `normalizeScore` should return the normalized score that you get after applying the normalization function to the score that was passed in.
103-
104-
```javascript
105-
function normalize(score) {
106-
return 2 * score + 10;
107-
}
108-
109-
const params = { score: 400, normalizeFunction: normalize };
110-
normalizeScore(params);
111-
// => 810
112-
```

exercises/concept/high-score-board/.meta/exemplar.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,3 @@ export function applyMondayBonus(scoreBoard) {
6363

6464
return scoreBoard;
6565
}
66-
67-
/**
68-
* Normalizes a score with the provided normalization function.
69-
*
70-
* @param {Params} params the parameters for performing the normalization
71-
* @returns {number} normalized score
72-
*/
73-
export function normalizeScore(params) {
74-
return params.normalizeFunction(params.score);
75-
}

exercises/concept/high-score-board/high-score-board.spec.js

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
addPlayer,
44
applyMondayBonus,
55
createScoreBoard,
6-
normalizeScore,
76
removePlayer,
87
updateScore,
98
} from './high-score-board';
@@ -130,27 +129,3 @@ describe('applyMondayBonus', () => {
130129
expect(Object.is(actual, scoreBoard)).toBe(true);
131130
});
132131
});
133-
134-
describe('normalizeScore', () => {
135-
test('applies the normalization function', () => {
136-
const params = {
137-
score: 45,
138-
normalizeFunction: function (score) {
139-
return score * 3 - 10;
140-
},
141-
};
142-
143-
expect(normalizeScore(params)).toEqual(125);
144-
});
145-
146-
test('works for different params', () => {
147-
const params = {
148-
score: 2100,
149-
normalizeFunction: function (score) {
150-
return score / 2 + 100;
151-
},
152-
};
153-
154-
expect(normalizeScore(params)).toEqual(1150);
155-
});
156-
});

0 commit comments

Comments
 (0)