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

The task is completed #233

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

Conversation

AndruhaMan
Copy link

No description provided.

Copy link

@maxim2310 maxim2310 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 overall! Just couple tiny things needs to be fixed before approval)

Comment on lines 5 to 17
module.exports.generateNumber = () => {
const digitsArray = [];

while (digitsArray.length < NUM_LENGTH) {
const numToPush = Math.floor(Math.random() * 10);

if (!digitsArray.includes(numToPush)) {
digitsArray.push(numToPush);
}
}

return digitsArray.join('');
};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you func cant create number with duplicate number and can create number that start from 0, that not so logic

Comment on lines 7 to 9
if (number[i] === number[i - 1]) {
return false;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this redundant but why do you think that the same number will be placed only together

Comment on lines 11 to 23
for (let i = 0; i < NUM_LENGTH; i++) {
const isBull = enteredNumberCopy[0] === numberToGuessCopy[0];
const isCow = numberToGuess.includes(enteredNumberCopy[0]);

if (isBull) {
bullsCount++;
} else if (isCow) {
cowsCount++;
}

numberToGuessCopy.shift();
enteredNumberCopy.shift();
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (let i = 0; i < NUM_LENGTH; i++) {
const isBull = enteredNumberCopy[0] === numberToGuessCopy[0];
const isCow = numberToGuess.includes(enteredNumberCopy[0]);
if (isBull) {
bullsCount++;
} else if (isCow) {
cowsCount++;
}
numberToGuessCopy.shift();
enteredNumberCopy.shift();
}
for (let i = 0; i < NUM_LENGTH; i++) {
const isBull = enteredNumberCopy[0] === numberToGuessCopy[i];
const isCow = numberToGuess.includes(enteredNumberCopy[i]);
if (isBull) {
bullsCount++;
} else if (isCow) {
cowsCount++;
}
}

Copy link

@anastasiiavorobiova anastasiiavorobiova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

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