https://github.com/asmeikal/keypad-lib
A keypad class that uses Decimal, which is better than using strings.
https://github.com/asmeikal/keypad-lib
Last synced: 2 months ago
JSON representation
A keypad class that uses Decimal, which is better than using strings.
- Host: GitHub
- URL: https://github.com/asmeikal/keypad-lib
- Owner: asmeikal
- License: mit
- Created: 2019-04-18T19:31:02.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-03T19:57:10.000Z (over 2 years ago)
- Last Synced: 2025-02-21T05:34:52.509Z (3 months ago)
- Language: TypeScript
- Size: 868 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Keypad


This is a challenge.
Implement a keypad utility class, with the following methods:
* add a digit to the keypad
* add two zeros to the keypad
* remove a digit to the keypad
* convert keypad to a stringThe keypad constructor takes the max number of integer digits and the number of decimal places.
The keypad is immutable.
```typescript
const Keypad = require('keypad-lib').Keypad;
// import { Keypad } from 'keypad-lib';let d = new Keypad(7,2);
console.log(d.toString());
// outputs "0.00"d = d.addDigit(1)
.addDigit(2)
.addDigit(3)
.addDigit(4)
.addDigit(5)
.addDigit(6)
.addDigit(7)
.addDigit(8)
.addDigit(9)
.addDigit(0);console.log(d.toString());
// outputs "1234567.89"
```