File tree Expand file tree Collapse file tree 3 files changed +34
-1
lines changed Expand file tree Collapse file tree 3 files changed +34
-1
lines changed Original file line number Diff line number Diff line change 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 ( ) ;
Original file line number Diff line number Diff line change 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" ,
Original file line number Diff line number Diff line change 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 ;
You can’t perform that action at this time.
0 commit comments