aristotles / sample-function-testing

JavaScript Function/Algorithmic testing application

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

JavaScript Function/Algorithmic testing application


Languages

Language:JavaScript 100.0%