Skip to content

Commit 22216d5

Browse files
committed
8. not a working version progression.js
1 parent 46dfe5e commit 22216d5

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

bin/brain-progression.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env node
2+
import { welcomeUser } from '../src/games/cli.js';
3+
import actionGame from '../src/games/progression.js';
4+
5+
welcomeUser();
6+
actionGame();

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"brain-games": "bin/brain-games.js",
2323
"brain-even": "bin/brain-even.js",
2424
"brain-calc": "bin/brain-calc.js",
25-
"brain-gcd": "bin/brain-gcd.js"
25+
"brain-gcd": "bin/brain-gcd.js",
26+
"brain-progression": "bin/brain-progression.js"
2627
},
2728
"dependencies": {
2829
"lodash": "^4.17.21",

src/games/progression.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import roundGame from '../index.js';
2+
import randomNumber from '../utilRandomNumber.js';
3+
4+
const descriptionGame = 'What number is missing in the progression?';
5+
6+
const actionGame = () => {
7+
const progression = [];
8+
for (let i = 0; i < 10; i += 1) {
9+
progression.push(randomNumber());
10+
}
11+
const arithmeticProgression = progression.sort((a, b) => a - b);
12+
const hiddenNum = randomNumber(10);
13+
const correctAnswer = arithmeticProgression[hiddenNum];
14+
arithmeticProgression[hiddenNum] = '..';
15+
let question = '';
16+
arithmeticProgression.forEach((element) => {
17+
question += `${element} `;
18+
});
19+
return [question, String(correctAnswer)];
20+
};
21+
22+
const progressionGame = () => {
23+
console.log(descriptionGame);
24+
roundGame(actionGame);
25+
};
26+
export default progressionGame;

0 commit comments

Comments
 (0)