keypad-lib
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

Keypad

Travis (.com) Coveralls github npm

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 string

The keypad constructor takes the max number of integer digits and the number of decimal places.

The keypad is immutable.

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"

Readme

Keywords

none

Package Sidebar

Install

npm i keypad-lib

Weekly Downloads

2

Version

0.1.2

License

MIT

Unpacked Size

5.06 kB

Total Files

7

Last publish

Collaborators

  • asmeikal