-
Notifications
You must be signed in to change notification settings - Fork 530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
create cli game #252
base: master
Are you sure you want to change the base?
create cli game #252
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great job!
src/constants.js
Outdated
= 'You printed something wrong (>_<). Pwease, try again (ノ◕ヮ◕)ノ'; | ||
const WELCOME_MESSAGE | ||
= `Enter ${gameNumberSize} digits pwease (◕‿◕✿): `; | ||
const VICTORY_MESSAGE | ||
= 'Wow, you won! (づ ◕‿◕ )づ'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎀✨😍
src/constants.js
Outdated
@@ -0,0 +1,17 @@ | |||
'use strict'; | |||
|
|||
const gameNumberSize = 4; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be in UPPER_CASE
src/generateFixedSizeNumber.js
Outdated
for (let i = 0; i < length; i++) { | ||
const randomIndex = Math.floor(Math.random() * digits.length); | ||
|
||
number += digits[randomIndex]; | ||
digits = digits.slice(0, randomIndex) + digits.slice(randomIndex + 1); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be better if you will generate your number like this const randomDigit = Math.floor(Math.random() * 10);
In this case you don't need additional variable and operations with slice
, but your solution is interesting 👍
src/app.js
Outdated
if (gameNumber === userNumber) { | ||
console.log(VICTORY_MESSAGE); | ||
break; | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid using else
const secret = realNumber.toString(10).split(''); | ||
const guess = playerNumber.toString(10).split(''); | ||
|
||
for (let i = 0; i < 4; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4 is a magic value
No description provided.