8000 GitHub - PhilipRejiRajan/Slot-Machine: learning javascript
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

PhilipRejiRajan/Slot-Machine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Slot Machine

Slot Machine is a very basic terminal game. I used this video to learn how to make it.

⚙️ Prerequisites:

  • Node.js v22.15.0
  • install package: npm install prompt-sync

🏃‍♂️‍➡️ Running the Slot Machine:

cd Slot Machine
npm start

Output:

Enter a deposit am
5A0C
ount: 1000
You have a balance of $1000
Enter the number of lines to bet on (1-3): 2
Enter the bet per line: 100
A | D | A
D | C | B
B | D | C
You won, $0
Do you want to play again (y/n)? y
You have a balance of $800
Enter the number of lines to bet on (1-3): 1
Enter the bet per line: 100
D | D | D
C | C | C
C | C | D
You won, $200
Do you want to play again (y/n)? n

✅ Testing:

  • install package: npm install --save-dev jest
  • running the test: npm test

Sample Output:

 PASS  ./gameLogic.test.js
  Game Logic
    √ transpose() should correctly transpose a 2D array (4 ms)
    √ getWinnings() should return correct winnings for matching row (1 ms)
    √ spin() should return correct number of reels and symbols (2 ms)

Test Suites: 1 passed, 1 total
Tests:       3 passed, 3 total
Snapshots:   0 total
Time:        0.624 s, estimated 1 s
Ran all test suites.

About

learning javascript

Topics

Resources

Stars

Watchers

Forks

0