Giter Site home page Giter Site logo

bartprokop / challenge-build-your-own-array-in-js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from waterlink/challenge-build-your-own-array-in-js

0.0 1.0 0.0 489 KB

This is a challenge that will allow you to practice your logical, analytical and problem-solving skills. Additionally, by the end of it you’ll have much better command of arrays in javascript.

License: MIT License

HTML 0.35% JavaScript 99.65%

challenge-build-your-own-array-in-js's Introduction

Challenge “Build Your Own Array in Javascript!”

Rules are simple:

  • I give you a test suite for (almost) all the functionality of the array.
  • You implement that functionality in the class MyArray.
  • You can’t use standard javascript’s Array, instead you need to use the provided wrapper PlainArray that limits what you can do:
class PlainArray<T> {
    constructor(capacity: number)
    length: number
    get(index: number): T
    set(index: number, value: T)
}
  • PlainArray is a fixed-size array that has one property and two methods defined: length, get(index) and set(index, value).
  • Even though the definition of that class is in Typescript, you will have to use vanilla ECMA Script 5.
  • Focus more on readability over the performance.

How to Run The Test Suite?

First, you’ll need to clone this repository:

$ git clone https://github.com/waterlink/Challenge-Build-Your-Own-Array-In-Js
$ cd Challenge-Build-Your-Own-Array-In-Js

You will need to open SpecRunner.html in your browser. You can launch it from the directory in your file explorer, or you could run it from terminal:

# Mac OS X:
$ open ./SpecRunner.html

# Most Linuxes
$ xdg-open ./SpecRunner.html

You should see something like that:

To see the test suite open ./spec/MyArraySpec.js and start making these failing tests pass one by one.

I recommend starting with the top ones, as they get harder towards the bottom.

Why?

So that you can practice your logical and problem-solving skills.

Additionally, by the end of this challenge, you’ll have much more mastery over the use of arrays in javascript.

I’m Done. Now What?

Send me a pull request to this GitHub repository. And take a look at everyone else’s solution, as well!

Just don’t peek before you are done ;)

Thank you!

challenge-build-your-own-array-in-js's People

Contributors

bartprokop avatar ilonacodes avatar waterlink 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.