Skip to content
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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

create cli game #252

wants to merge 7 commits into from

Conversation

neovendano
Copy link

No description provided.

Copy link

@polinavafik polinavafik left a 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
Comment on lines 6 to 10
= 'You printed something wrong (>_<). Pwease, try again (ノ◕ヮ◕)ノ';
const WELCOME_MESSAGE
= `Enter ${gameNumberSize} digits pwease (◕‿◕✿): `;
const VICTORY_MESSAGE
= 'Wow, you won! (づ ◕‿◕ )づ';

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;

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

Comment on lines 7 to 12
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);
}

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 {

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++) {

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants