-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
929d405
commit 3995dc7
Showing
7 changed files
with
65 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
env: | ||
node: true | ||
es2021: true | ||
extends: | ||
- 'airbnb-base' | ||
parserOptions: | ||
ecmaVersion: latest | ||
sourceType: module | ||
rules: | ||
no-console: 0 | ||
import/extensions: | ||
- error | ||
- ignorePackages | ||
- js: always | ||
# env: | ||
# node: true | ||
# es2021: true | ||
# extends: | ||
# - 'airbnb-base' | ||
# parserOptions: | ||
# ecmaVersion: latest | ||
# sourceType: module | ||
# rules: | ||
# no-console: 0 | ||
# import/extensions: | ||
# - error | ||
# - ignorePackages | ||
# - js: always | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,9 @@ brain-games: | |
|
||
publish: | ||
npm publish --dry-run | ||
|
||
lint: | ||
npx eslint . | ||
npx eslint . | ||
|
||
brain-even: | ||
node bin/brain-even.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import readlineSync from 'readline-sync'; | ||
|
||
|
||
const isEvenNum = () => { | ||
const number = Math.floor(Math.random() * 100); | ||
console.log(`Question: ${number}`); | ||
const answer = readlineSync.question('Your answer:'); | ||
const name = greetGamer(); | ||
if (number % 2 === 0) { | ||
const answerYes = 'Correct!'; | ||
const answerNo = `'no' is wrong answer ;(. Correct answer was 'yes'.\nLet\'s try again, ${name}!`; | ||
switch (answer) { | ||
case 'yes': | ||
console.log(answerYes); | ||
return true; | ||
case 'no': | ||
console.log(answerNo); | ||
return false; | ||
default: | ||
console.log(answerNo); | ||
return false; | ||
} | ||
} | ||
else if (number % 2 !== 0) { | ||
const answerYes = `'yes' is wrong answer ;(. Correct answer was 'no'.\nLet\'s try again, ${name}!`; | ||
const answerNo = 'Correct!'; | ||
switch (answer) { | ||
case 'yes': | ||
console.log(answerYes); | ||
return false; | ||
case 'no': | ||
console.log(answerNo); | ||
return true; | ||
default: | ||
console.log(answerNo); | ||
return false; | ||
} | ||
} | ||
}; | ||
isEvenNum(); | ||
export default isEvenNum; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
#!/usr/bin/env node | ||
|
||
import greetGamer from '../src/cli.js'; | ||
import isEvenNum from './brain-even.js'; | ||
|
||
greetGamer(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters