Giter Site home page Giter Site logo

sample-function-testing's Introduction

Testing Functions Sample Project

By Sam Kratsas

Written in JavaScript
Run test command:
npm test

Tasks

Problem 1

Given an input string, return a new "cleaned-up" string with any non-numeric characters removed. For example: an input of: "7-623" should return: "7623" and an input of: "..2965a" should return "2965"

Problem 2

Given a list of elements (where all elements are of the same type), return a new list with the same elements in the same order, but removing duplicates. Preserve the original input - do not mutate it, return a new list instead. For example, an input of: ["a", "b", "c", "a", "b", "d"] should return: ["a", "b", "c", "d"] and an input of: [4, 4, 3, 2, 3, 1] should return: [4, 3, 2, 1]

Problem 3

Given a list of string IDs (possibly with duplicates) and a list of specialties with IDs, return a list of specialty names, without duplicates, that are represented by the given IDs (after being "cleaned up" by the process from step one). For example, given this list of IDs: ["7-623", "8235", "8-235"] and this list of specialties (the first item being a canonical ID): [[1381, "front-end web development"], [8235, "data engineering"], [3434, "API design"], [7623, "security"], [9153, "UX"]] your code should return: ["security", "data engineering"] You can assume there are no duplicates in the list of specialties: no ID will appear for multiple specialty areas. Note that this specialties list should have real numbers as the IDs, not just strings with numeric characters.

Next Steps

I believe good code is subjective and can never be perfect, constant updating and improvements are always needed. So when it was time to stop this project there were still many things I could have added, including:

  • More tests for each function, and testing different methods paired together.
  • Checking types and edge cases, most of these I assumed were covered by the strict instructions given(i.e. the array would all be of the same type).
  • Instead of having different methods, Array.prototype could be polymorphed to add the methods directly to the array object.

sample-function-testing's People

Watchers

Aristotles Kratsas 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.