Coder Social home page Coder Social logo

js-test's Introduction

VoxSmart JavaScript coding test

Fill in number-parser.js to ensure that the tests in number-parser.test.js succeed.

Each test case calls NumberParser.internationalize(givenNumber, referenceNumber), which must

  • return the givenNumber if it's already in international format
  • otherwise, internationalize givenNumber, assuming it's been given in the national format of the referenceNumber

In a typical VoxSmart situation, the referenceNumber might be the user's own phone number.

The NumberParser is initialized with a country database: you are given a small sample database in the test code. Each item in the database contains

  • a country code
  • an international prefix, eg +44 for the UK
  • the national prefix, eg 1 for the US; this defaults to 0

The test cases show the required behaviour when valid parameters are given, and also a couple of cases of invalid data which should cause exceptions.

Your answer must be source code for number-parser.js, which can be dropped in as a replacement for the suppied number-parser.js and which will produce a 100% pass with the given test code.

js-test's People

Contributors

alinamihai avatar

Watchers

 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.