File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change 1+ #!/usr/bin/env node
2+
3+ import run from '../src/games/progression.js' ;
4+
5+ run ( ) ;
Original file line number Diff line number Diff line change 1+ import playGame from '../index.js' ;
2+
3+ const rules = 'What number is missing in the progression?' ;
4+
5+ const findNumberInProgression = ( ) => {
6+ const increasedBy = Math . floor ( Math . random ( ) * 10 ) + 1 ;
7+ let progressionNumber = Math . floor ( Math . random ( ) * 50 ) ;
8+ const progression = [ progressionNumber ] ;
9+
10+ for ( let i = 1 ; i < 10 ; i += 1 ) {
11+ progressionNumber += increasedBy ;
12+ progression . push ( progressionNumber ) ;
13+ }
14+
15+ const position = Math . floor ( Math . random ( ) * 10 ) ;
16+ const correctAnswer = progression [ position ] ;
17+ progression [ position ] = '..' ;
18+
19+ return [ progression . join ( ' ' ) , String ( correctAnswer ) ] ;
20+ } ;
21+
22+ export default ( ) => playGame ( rules , findNumberInProgression ) ;
You can’t perform that action at this time.
0 commit comments