File tree Expand file tree Collapse file tree 4 files changed +36
-1
lines changed Expand file tree Collapse file tree 4 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,8 @@ brain-calc:
88 node bin/brain-calc.js
99brain-gcd :
1010 node bin/brain-gcd.js
11+ brain-progression :
12+ node bin/brain-progression.js
1113publish :
1214 npm publish --dry-run
1315lint :
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env node
2+
3+ import gamePRG from "../src/brainPGRESS.js" ;
4+
5+ gamePRG ( ) ;
Original file line number Diff line number Diff line change 88 "brain-games" : " bin/brain-games.js" ,
99 "brain-even" : " bin/brain-even.js" ,
1010 "brain-calc" : " bin/brain-calc.js" ,
11- "brain-gcd" : " bin/brain-gcd.js"
11+ "brain-gcd" : " bin/brain-gcd.js" ,
12+ "brain-progression" : " bin/brain-progression.js"
1213 },
1314 "scripts" : {
1415 "test" : " echo \" Error: no test specified\" && exit 1"
Original file line number Diff line number Diff line change 1+ import { getRandomNum } from "./brainEven.js" ;
2+ import { TheMotor } from "../index.js" ;
3+ const genPRG = ( length , firstElem , prgStep ) => {
4+ const progression = [ ] ;
5+ for ( let i = 0 ; i < length ; i += 1 ) {
6+ progression . push ( firstElem + prgStep * i ) ;
7+ }
8+ return progression ;
9+ }
10+ const alert = "What number is missing in the progression?" ;
11+ const genRounds = ( ) => {
12+ const progressionLength = 10 ;
13+ const firstElem = getRandomNum ( 1 , 10 ) ;
14+ const prgStep = getRandomNum ( 2 , 10 ) ;
15+ const progression = genPRG ( progressionLength , firstElem , prgStep ) ;
16+ const indexOfHide = getRandomNum ( 0 , progressionLength - 1 ) ;
17+ const hiddenElem = progression [ indexOfHide ] ;
18+ progression [ indexOfHide ] = ".." ;
19+ const question = progression . join ( " " ) ;
20+ const rightAnswer = hiddenElem . toString ( ) ;
21+ return [ question , rightAnswer ] ;
22+
23+ }
24+ const gamePRG = ( ) => {
25+ TheMotor ( alert , genRounds ) ;
26+ }
27+ export default gamePRG ;
You can’t perform that action at this time.
0 commit comments