-
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
The task is completed #233
base: master
Are you sure you want to change the base?
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 overall! Just couple tiny things needs to be fixed before approval)
src/generateNumber.js
Outdated
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(''); | ||
}; |
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.
you func cant create number with duplicate number and can create number that start from 0, that not so logic
src/validateNumber.js
Outdated
if (number[i] === number[i - 1]) { | ||
return false; | ||
} |
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.
this redundant but why do you think that the same number will be placed only together
src/bullsAndCows.js
Outdated
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(); | ||
} |
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.
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++; | |
} | |
} |
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 work!
No description provided.