Coder Social home page Coder Social logo

calculator-challenge's Introduction

A Calculator Challenge

Requirements

  • 1. Support a maximum of 2 numbers using a comma delimiter * examples: 20 will return 20; 1,5000 will return 5001 * invalid/missing numbers should be converted to 0 e.g. "" will return 0; 5,tytyt will return 5
  • 2. Support an unlimited number of numbers e.g. 1,2,3,4,5,6,7,8,9,10,11,12 will return 78
  • 3. Support a newline character as an alternative delimiter e.g. 1\n2,3 will return 6
  • 4. Deny negative numbers. An exception should be thrown that includes all of the negative numbers provided
  • 5. Ignore any number greater than 1000 e.g. 2,1001,6 will return 8
  • 6. Support 1 custom single character length delimiter * use the format: //{delimiter}\n{numbers} e.g. //;\n2;5 will return 7 * all previous formats should also be supported
  • 7. Support 1 custom delimiter of any length * use the format: //[{delimiter}]\n{numbers} e.g. //[***]\n11***22***33 will return 66 * all previous formats should also be supported
  • 8. Support multiple delimiters of any length * use the format: //[{delimiter1}][{delimiter2}]...\n{numbers} e.g. //[*][!!][r9r]\n11r9r22*33!!44 will return 110 * all previous formats should also be supported

To run

  1. npm install
  2. inside the project root folder: node .

Commands

  1. npm run test - runs the test suite

calculator-challenge's People

Contributors

xevnik avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.