Skip to content

Commit b8cabdd

Browse files
committed
error correction
1 parent 678c9ce commit b8cabdd

File tree

14 files changed

+64
-77
lines changed

14 files changed

+64
-77
lines changed

bin/brain-calc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env node
22
import playGameCalc from '../src/games/brain-calc.js';
33

4-
playGameCalc();
4+
playGameCalc();

bin/brain-even.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env node
22
import playGameEven from '../src/games/brain-even.js';
33

4-
playGameEven();
4+
playGameEven();

bin/brain-games.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env node
2-
import greetings from "../src/cli.js";
2+
import greetings from '../src/cli.js';
33

44
greetings();

bin/brain-gcd.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env node
22
import playGameGCD from '../src/games/brain-gcd.js';
33

4-
playGameGCD();
4+
playGameGCD();

bin/brain-prime.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env node
22
import playGamePrime from '../src/games/brain-prime.js';
33

4-
playGamePrime();
4+
playGamePrime();

bin/brain-progression.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env node
22
import playGameProgression from '../src/games/brain-progression.js';
33

4-
playGameProgression();
4+
playGameProgression();

eslint.config.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
import globals from "globals";
2-
import pluginJs from "@eslint/js";
3-
1+
import globals from 'globals';
2+
import pluginJs from '@eslint/js';
43

54
/** @type {import('eslint').Linter.Config[]} */
65
export default [
7-
{languageOptions: { globals: globals.node }},
6+
{ languageOptions: { globals: globals.node } },
87
pluginJs.configs.recommended,
98
{
10-
rules: {
11-
'import/no-named-as-default': 'off',
12-
'import/no-named-as-default-member': 'off',
13-
'no-console': 'off',
14-
'import/no-extraneous-dependencies': 'off',
15-
}
16-
}
9+
rules: {
10+
'import/no-named-as-default': 'off',
11+
'import/no-named-as-default-member': 'off',
12+
'no-console': 'off',
13+
'import/no-extraneous-dependencies': 'off',
14+
},
15+
},
1716
];

src/cli.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import readlineSync from "readline-sync";
1+
import readlineSync from 'readline-sync';
22

3-
const greetings =() => {
4-
console.log("Welcome to the Brain Games!");
3+
const greetings = () => {
4+
console.log('Welcome to the Brain Games!');
55
const userName = readlineSync.question("May I have your name?");
6-
console.log("Hello, " + userName + "!");
6+
console.log('Hello, ' + userName + '!');
77
return userName;
88
};
99
export default greetings;

src/games/brain-calc.js

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,32 @@
11
import playGame from '../index.js';
22

3-
const getRandomExpression = () => {
4-
const num1 = Math.floor(Math.random() * 100) + 1;
5-
const num2 = Math.floor(Math.random() * 100) + 1;
6-
const operations = ['+', '-', '*'];
7-
const operation = operations[Math.floor(Math.random() * operations.length)];
8-
const expression = `${num1} ${operation} ${num2}`;
9-
let correctAnswer;
10-
11-
switch (operation) {
12-
case '+':
13-
correctAnswer = num1 + num2;
14-
break;
15-
case '-':
16-
correctAnswer = num1 - num2;
17-
break;
18-
case '*':
19-
correctAnswer = num1 * num2;
20-
break;
21-
}
22-
return { question: expression, correctAnswer };
3+
const getRandomExpression = () => {
4+
const num1 = Math.floor(Math.random() * 100) + 1;
5+
const num2 = Math.floor(Math.random() * 100) + 1;
6+
const operations = ['+', '-', '*'];
7+
const operation = operations[Math.floor(Math.random() * operations.length)];
8+
const expression = `${num1} ${operation} ${num2}`;
9+
let correctAnswer;
10+
11+
switch (operation) {
12+
case '+':
13+
correctAnswer = num1 + num2;
14+
break;
15+
case '-':
16+
correctAnswer = num1 - num2;
17+
break;
18+
case '*':
19+
correctAnswer = num1 * num2;
20+
break;
21+
default:
22+
console.log('Ошибка');
23+
}
24+
return { question: expression, correctAnswer };
2325
};
2426

25-
const playGameCalc = () => {
26-
const gameQuestion = 'What is the result of the expression?';
27-
playGame(getRandomExpression, gameQuestion);
28-
};
27+
const playGameCalc = () => {
28+
const gameQuestion = 'What is the result of the expression?';
29+
playGame(getRandomExpression, gameQuestion);
30+
};
2931

30-
export default playGameCalc;
32+
export default playGameCalc;

src/games/brain-even.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@ import playGame from '../index.js';
22

33
const getRandomNumber = () => Math.floor(Math.random() * 100) + 1;
44
const isEven = (number) => number % 2 === 0;
5-
65
const getQuestionAndAnswer = () => {
76
const number = getRandomNumber();
87
const question = number;
98
const correctAnswer = isEven(number) ? 'yes' : 'no';
109
return { question, correctAnswer };
1110
};
12-
1311
const playGameEven = () => {
1412
const gameQuestion = 'Answer "yes" if the number is even, otherwise answer "no".';
1513
playGame(getQuestionAndAnswer, gameQuestion);
1614
};
17-
15+
1816
export default playGameEven;

0 commit comments

Comments
 (0)