Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
JasterHim committed Sep 30, 2023
1 parent 736e084 commit 31842be
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ const game = () => {
return;
}

const result = calculateResult(gemeratNumber, normalizePresume.split(''));
const result = calculateResult(
gemeratNumber.split(''),
normalizePresume.split(''),
);

if (result.bulls !== 4) {
console.log(`Bulls: ${result.bulls}, Cows: ${result.cows}`);
Expand Down
4 changes: 2 additions & 2 deletions src/calculateResult.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ const calculateResult = (answer, assumption) => {
let cows = 0;

for (let i = 0; i < 4; i++) {
if (answer[i] === +assumption[i]) {
if (+answer[i] === +assumption[i]) {
bulls++;
} else if (answer.includes(+assumption[i])) {
} else if (answer.includes(assumption[i])) {
cows++;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/randomDigits.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const getRandomNumber = () => {
result.push(kitDigits.splice(indexDidit, 1));
}

return result;
return result.join('');
};

module.exports = {
Expand Down

0 comments on commit 31842be

Please sign in to comment.