|
1 | | -import runEngine from '../index.js'; |
2 | | -import getRandomNumber from '../utils.js'; |
| 1 | +import runEngine from '../index.js' |
| 2 | +import getRandomNumber from '../utils.js' |
3 | 3 |
|
4 | | -const rule = 'What is the result of the expression?'; |
| 4 | +const rule = 'What is the result of the expression?' |
5 | 5 |
|
6 | 6 | const getCalculation = () => { |
7 | | - const a = getRandomNumber(1, 50); |
8 | | - const b = getRandomNumber(1, 50); |
9 | | - const operators = ['+', '-', '*']; |
10 | | - const op = operators[getRandomNumber(0, operators.length - 1)]; |
| 7 | + const a = getRandomNumber(1, 50) |
| 8 | + const b = getRandomNumber(1, 50) |
| 9 | + const operators = ['+', '-', '*'] |
| 10 | + const op = operators[getRandomNumber(0, operators.length - 1)] |
11 | 11 |
|
12 | | - let correctAnswer; |
| 12 | + let correctAnswer |
13 | 13 | switch (op) { |
14 | 14 | case '+': |
15 | | - correctAnswer = a + b; |
16 | | - break; |
| 15 | + correctAnswer = a + b |
| 16 | + break |
17 | 17 | case '-': |
18 | | - correctAnswer = a - b; |
19 | | - break; |
| 18 | + correctAnswer = a - b |
| 19 | + break |
20 | 20 | case '*': |
21 | | - correctAnswer = a * b; |
22 | | - break; |
| 21 | + correctAnswer = a * b |
| 22 | + break |
23 | 23 | } |
24 | 24 |
|
25 | | - return [`${a} ${op} ${b}`, String(correctAnswer)]; |
26 | | -}; |
| 25 | + return [`${a} ${op} ${b}`, String(correctAnswer)] |
| 26 | +} |
27 | 27 |
|
28 | | -const startCalcGame = () => runEngine(rule, getCalculation); |
| 28 | +const startCalcGame = () => runEngine(rule, getCalculation) |
29 | 29 |
|
30 | | -export default startCalcGame; |
| 30 | +export default startCalcGame |
0 commit comments