Giter Site home page Giter Site logo

ts-datastructurekata's Introduction

Kata: Data Structures

This challenge is designed to practice interacting with JavaScript objects, pulling values from objects and testing the outcome of these in controlled tests.

Setup

Clone this repo, then:

cd kata-data-structures
npm install

Kata with tests

First, take a look at the files in the tests folder and examine how the tests are structured. You don't have to read and understand every single test before beginning! Instead, notice the rhythm that the tests exhibit:

  • Arrange: set up some data to use in the test, especially state what we expect to happen
  • Act: call the function that is being tested, so we can find out what actually happens
  • Assert: check to see if what we expected to happen actually happened!

Before working on a function, take turns explaining what each test is doing with your pair.

The first test

  • Run the first test using npm test getType. You'll notice the test is failing with a TypeError: getType is not a function. The test file is calling require on the correct file, but getType.js isn't exporting the function.

  • Open the folder in VS Code using code . and open getType.js.

  • Export the function by adding module.exports = getType and save the file. Now you'll notice the tests are failing for different reasons.

  • Implement the getType function:

    function getType (thing) {
      return typeof thing
    }
  • Now the tests should be passing. Type q to stop the test.

If you'd like to work on the tests in an order of increasing difficulty, try this order:

  • getType
  • getValue
  • getAddress
  • positions
  • getPropTypes
  • matrix
  • find
  • where

Making sure you're finished

To run all of the tests for all of the functions you've written, in terminal run:

npm test tests

This will run all tests in the tests directory. When you have all the tests passing, read your code through carefully and ensure you know everything that is going on. Can you refactor any of it? Does it all make sense to you?

Resources

ts-datastructurekata's People

Contributors

tausani-ah-chong 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.