Skip to content

Commit

Permalink
Solution
Browse files Browse the repository at this point in the history
  • Loading branch information
oleksii-bieliaiev committed Sep 19, 2023
1 parent 651e99f commit a061474
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const handleGameStart = (enteredNumber) => {

const secretNumber = numberGenerator();

console.log(secretNumber, enteredNumber);
console.log(`The secret number is ${secretNumber}`);

if (enteredNumber === secretNumber) {
console.log('You win!');
Expand Down
7 changes: 5 additions & 2 deletions src/numberGenerator.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
'use strict';

const numberLength = 4;
const toInteger = 10;

const numberGenerator = () => {
const numbersArr = [];

while (numbersArr.length < 4) {
const num = Math.floor(Math.random() * 10);
while (numbersArr.length < numberLength) {
const num = Math.floor(Math.random() * toInteger);

if (!numbersArr.includes(num)) {
numbersArr.push(num);
Expand Down

0 comments on commit a061474

Please sign in to comment.