Skip to content

Commit f9ee060

Browse files
authored
Fix tasks and tests (#20)
1 parent 4a1df82 commit f9ee060

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed

Exercises.en.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
You can often use more general functions to define more specific functions.
66

7-
- Define function `power()` which is an alias to `Math.pow()`.
8-
- Implement function `square()` which returns a number to the power of two.
9-
- `bind()` function `power(base, power)` to obtain function `cube(n)`.
7+
- Define function `power(exp, n)`, the same as `Math.pow(n, exp)` but with
8+
reverse order of argumants.
9+
- Implement function `square(n)` which returns a number to the power of two.
10+
- `bind()` function `power(exp, n)` to obtain function `cube(n)`.
1011

1112
## Use closure
1213

Exercises/1-power.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
'use strict';
22

3-
// Define function power - an alias to Math.pow().
3+
// Define function power(exp, n), the same as Math.pow(n, exp)
4+
// but with reverse order of argumants.
45
const power = null;
56

67
// Implement function `square(n)`, which returns square of its argument.
78
// The function may or may not reuse function `power`.
89
const square = null;
910

1011
// Implement function `cube(n)` using partial application
11-
// The function should return power of three for the given argument.
12+
// The function should return cube of argumant (to the power of three).
1213
const cube = null;
1314

1415
module.exports = { power, square, cube };

Exercises/1-power.test

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
[{
22
name: 'power',
3-
length: [32, 32],
3+
length: [24, 50],
44
cases: [
55
[0, 0, 1],
66
[1, 1, 1],
7-
[1, 2, 1],
8-
[2, 1, 2],
7+
[2, 1, 1],
8+
[1, 2, 2],
99
[2, 2, 4],
10-
[3, 1, 3],
11-
[3, 2, 9],
10+
[1, 3, 3],
11+
[2, 3, 9],
1212
[3, 3, 27],
13-
[1, -1, 1],
14-
[1, -2, 1],
15-
[2, -1, 0.5],
16-
[2, -2, 0.25],
13+
[-1, 1, 1],
14+
[-2, 1, 1],
15+
[-1, 2, 0.5],
16+
[-2, 2, 0.25],
1717
],
1818
test: power => {
1919
const src = power.toString();
20-
if (src !== 'function pow() { [native code] }') {
21-
throw new Error('Function power expected to be reference to Math.pow');
20+
if (src === 'function pow() { [native code] }') {
21+
throw new Error('Function power is not expected to be alias of Math.pow');
2222
}
2323
}
2424
}, {
2525
name: 'square',
26-
length: [10, 25],
26+
length: [16, 25],
2727
cases: [
2828
[5, 25],
2929
[6, 36],
@@ -39,8 +39,8 @@
3939
}
4040
},
4141
cases: [
42-
[2, 9],
42+
[2, 8],
4343
[3, 27],
44-
[4, 81],
44+
[4, 64],
4545
]
4646
}]

0 commit comments

Comments
 (0)