Skip to content

Commit

Permalink
fix generator
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxSchmide committed Aug 6, 2023
1 parent 26a94cc commit 3e79a4b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable space-before-function-paren */
/* eslint-disable no-console */
'use strict';

Expand Down
14 changes: 13 additions & 1 deletion src/generator.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
'use strict';

const generateRandomNumber = () => {
return Math.ceil(Math.random() * 10000);
const uniqueDigits = [];

while (uniqueDigits.length < 4) {
const digit = Math.floor(Math.random() * 10);

if (!uniqueDigits.includes(digit)) {
uniqueDigits.push(digit);
}
}

const resultNumber = uniqueDigits.join('');

return parseInt(resultNumber);
};

module.exports = { generateRandomNumber };

0 comments on commit 3e79a4b

Please sign in to comment.