Skip to content

Commit 7be1a86

Browse files
author
daria-z
committed
fix logic
fix for linter
1 parent 5f4e8d4 commit 7be1a86

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

bin/brain-even.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 { greeting, evenChecking } from '../src/cli.js';
2+
import { evenChecking } from '../src/cli.js';
33

4-
evenChecking(greeting());
4+
evenChecking();

src/games/evenChecking.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
import readlineSync from 'readline-sync';
22

3-
export default (name) => {
3+
export default () => {
4+
console.log('Welcome to the Brain Games!');
5+
6+
const name = readlineSync.question('May I have your name? ');
7+
console.log(`Hello, ${name}!`);
48
console.log('\'yes\' is wrong answer ;(. Correct answer was \'no\'.');
9+
510
for (let i = 1; i <= 3; i += 1) {
611
const number = Math.floor(Math.random() * 50);
712
console.log(`Question: ${number}`);
813
const userAnswer = readlineSync.question('Your answer: ');
914
const correctAnswer = number % 2 === 0 ? 'yes' : 'no';
10-
if (userAnswer === correctAnswer) {
11-
console.log('Correct!');
12-
} else {
15+
if (userAnswer !== correctAnswer) {
1316
console.log(`'${userAnswer}' is wrong answer ;( .Correct answer was '${correctAnswer}'.`);
14-
return console.log(`Let's try again, ${name}!`);
17+
console.log(`Let's try again, ${name}!`);
18+
return;
1519
}
20+
console.log('Correct!');
1621
}
17-
return console.log(`Congratulations, ${name}!`);
22+
console.log(`Congratulations, ${name}!`);
1823
};

0 commit comments

Comments
 (0)