Skip to content

Commit c48e146

Browse files
rootroot
authored andcommitted
fix all files which needs changes
1 parent 0c1812c commit c48e146

File tree

11 files changed

+55
-52
lines changed

11 files changed

+55
-52
lines changed

bin/brain-calc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env node
2-
import ReadyGameCalc from "../src/BrainCacl.js";
2+
import readyGameCalc from "../src/BrainCacl.js";
33

4-
ReadyGameCalc();
4+
readyGameCalc();

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
2-
import { gameven } from "../src/brainEven.js";
2+
import {gameven} from "../src/brainEven.js";
33

44
gameven();

bin/brain-gcd.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env node
22

3-
import ReadygameGCD from "../src/brainGCD.js";
3+
import readygameGCD from "../src/brainGCD.js";
44

5-
ReadygameGCD();
5+
readygameGCD();

index.js

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,3 @@
1-
import readlineSync from "readline-sync"
2-
export const needAnswers = 3;
3-
const TheMotor = (alert, feat) =>{
4-
const maxRoundCount = 3;
5-
6-
console.log('Welcome to the Brain Games!');
7-
const userName = readlineSync.question('May I have your name? ');
8-
console.log(`Hello, ${userName}!`);
9-
10-
console.log(alert);
11-
12-
for (let i = 1; i <= maxRoundCount; i += 1) {
13-
const roundData = feat();
14-
const [question, correctAnswer] = roundData;
15-
console.log(`Question: ${question}`);
16-
const userAnswer = readlineSync.question('Your answer: ');
17-
18-
if (userAnswer !== correctAnswer) {
19-
console.log(`"${userAnswer}" is wrong answer ;(. Correct answer was "${correctAnswer}"`);
20-
console.log(`Let's try again, ${userName}!`);
21-
22-
return;
23-
}
24-
25-
console.log('Correct!');
26-
}
27-
console.log(`Congratulations, ${userName}!`);
28-
};
1+
import { TheMotor } from "./src";
292

303
export {TheMotor};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@hexlet/code",
33
"version": "1.0.0",
44
"type": "module",
5-
"description": "[![Actions Status](https://github.com/aptart/frontend-project-44/actions/workflows/hexlet-check.yml/badge.svg)](https://github.com/aptart/frontend-project-44/actions)",
5+
"description": "frontend-project Hexlet brain games",
66
"main": "index.js",
77
"bin": {
88
"brain-games": "bin/brain-games.js",

src/BrainCacl.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { TheMotor } from "../index.js";
22
import { getRandomNum } from "./brainEven.js";
3-
const alert = 'What is the result of the expression?';
3+
const description = 'What is the result of the expression?';
44
const getResultOfExpression = (firstValue, operator, secondValue) => {
55
switch (operator) {
66
case '+':
@@ -29,8 +29,8 @@ const genRounds = () => {
2929
return [question, correctAnswer];
3030
};
3131

32-
const ReadyGameCalc = () => {
33-
TheMotor(alert, genRounds);
32+
const readyGameCalc = () => {
33+
TheMotor(description, genRounds);
3434
};
3535

36-
export default ReadyGameCalc;
36+
export default readyGameCalc;

src/brainEven.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ import { TheMotor } from '../index.js';
33
const getRandomNum = (min, max) => Math.floor(Math.random() * (max - min + 1) + min);
44

55

6-
const alert = '"yes" if the number is even, otherwise answer "no".';
7-
const Game = ()=>{
6+
const description = '"yes" if the number is even, otherwise answer "no".';
7+
const genRounds = ()=>{
88
const minNum = 1;
9-
const maxNum = 1000;
9+
const maxNum = 100;
1010
const randomNum = getRandomNum(minNum, maxNum);
1111
const rightAnswer = randomNum % 2 === 0 ? 'yes' : 'no';
1212
return [randomNum, rightAnswer];
1313

1414
}
1515
const gameven = () =>{
16-
TheMotor(alert, Game)
16+
TheMotor(description, genRounds)
1717
};
1818

1919
export {getRandomNum, gameven};

src/brainGCD.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
import { getRandomNum } from "./brainEven.js";
22
import { TheMotor } from "../index.js";
3-
const alert = "Find the greatest common divisor of given numbers.";
3+
const description = "Find the greatest common divisor of given numbers.";
44
const getNOD = (num1, num2)=>{
55
if (num1 === 0){
66
return num2;
77
}
88
return getNOD(num2 % num1, num1);
99
};
1010
const genRounds = ()=>{
11-
const num1 = getRandomNum(1, 250);
12-
const num2 = getRandomNum(1, 250);
11+
const num1 = getRandomNum(1, 100);
12+
const num2 = getRandomNum(1, 100);
1313
const question = `${num1} ${num2}`;
1414
const NOD = getNOD(num1, num2);
1515
const correctAnswer = NOD.toString();
1616
return [question, correctAnswer];
1717

1818
}
19-
const ReadygameGCD = ()=>{
20-
TheMotor(alert, genRounds)
19+
const readygameGCD = ()=>{
20+
TheMotor(description, genRounds)
2121
};
22-
export default ReadygameGCD;
22+
export default readygameGCD;

src/brainPGRESS.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const genPRG = (length, firstElem, prgStep)=>{
77
}
88
return progression;
99
}
10-
const alert = "What number is missing in the progression?";
10+
const description = "What number is missing in the progression?";
1111
const genRounds = () =>{
1212
const progressionLength = 10;
1313
const firstElem = getRandomNum(1, 10);
@@ -22,6 +22,6 @@ const genRounds = () =>{
2222

2323
}
2424
const gamePRG = () =>{
25-
TheMotor(alert, genRounds);
25+
TheMotor(description, genRounds);
2626
}
2727
export default gamePRG;

src/brainPrime.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ const isPrime = (num)=>{
1111
};
1212
return true;
1313
};
14-
const alert = "Answer 'yes' if given number is prime. Otherwise answer 'no'.";
14+
const description = "Answer 'yes' if given number is prime. Otherwise answer 'no'.";
1515
const genRounds = ()=>{
1616
const question = getRandomNum(1, 1000)
1717
const rightAnswer = isPrime(question) ? "yes": "no";
1818
return [question, rightAnswer];
1919

2020
}
2121
const gamePrime = ()=>{
22-
TheMotor(alert, genRounds);
22+
TheMotor(description, genRounds);
2323
}
2424
export default gamePrime;
2525

0 commit comments

Comments
 (0)