@@ -4,30 +4,31 @@ import getRandomInRange from '../utils.js';
44
55const questionGame = 'What number is missing in the progression?' ;
66
7- const questionRound = ( ) => {
7+ const progression = ( startNumb , pogrlength , progrStep ) => {
8+ const arr = [ ] ;
9+ for ( let i = 0 ; i <= pogrlength ; i += 1 ) {
10+ arr . push ( startNumb + i * progrStep ) ;
11+ }
12+ return arr ;
13+ } ;
14+
15+ const generateRound = ( ) => {
816 const number = getRandomInRange ( ) ;
917 const length = getRandomInRange ( 5 , 10 ) ;
1018 const step = getRandomInRange ( 1 , 10 ) ;
1119 const itemSkip = getRandomInRange ( 2 , length ) ;
12- const progression = ( ) => {
13- const arr = [ ] ;
14- for ( let i = 0 ; i <= length ; i += 1 ) {
15- arr . push ( number + i * step ) ;
16- }
17- return arr ;
18- } ;
1920
20- const result = progression ( ) [ itemSkip ] . toString ( ) ;
21+ const answer = progression ( number , length , step ) [ itemSkip ] . toString ( ) ;
2122
22- const arrProgression = progression ( ) ;
23+ const arrProgression = progression ( number , length , step ) ;
2324 /* eslint-disable no-unused-vars */
2425 const skipItem = arrProgression . splice ( [ itemSkip ] , 1 , '..' ) ;
2526 /* eslint-enable no-unused-vars */
2627 const question = `Question: ${ arrProgression . join ( ' ' ) } ` ;
2728
28- return [ question , result ] ;
29+ return [ question , answer ] ;
2930} ;
3031
31- const progressionGame = ( ) => playGame ( questionGame , questionRound ) ;
32+ const progressionGame = ( ) => playGame ( questionGame , generateRound ) ;
3233
3334export default progressionGame ;
0 commit comments