GithubHelp home page GithubHelp logo

lab-es6-javascript-koans's Introduction

logo_ironhack_blue 7

ES6 JavaScript Koans

Introduction

We already did an exercise using Koans methodology on the first module. Koans are an excellent way for practice some fundamentals of the programming language we are learning. In this case, we will continue practicing JavaScript, but using the ES6 features we learned!

Just to a quick reminder, let's remember a bit about Koans!

What are the Koans?

Koans (ๅ…ฌๆกˆ) originate from Zen Buddhism. They are paradoxical riddles or stories which are used to test students on their path to enlightenment. They are designed to provoke thought or doubt in the student's mind. We are here to learn to code, so... what are the Koans?

The Koans are a series of assertions you must solve to understand how a programming language works. These assertions are the first step to become a better developer. The Koans become increasingly more difficult as you continue, so don't feel discouraged as you move forward through them.

There are Koans for all the programming languages. We will be working with JavaScript Koans. The mechanism is the following:

  • You get an assertion that is not passing a test.
  • You need to change/add code to make the test pass.

We are going to test the code assertions through Jasmine. Here we have introduced two new concepts: Testing and Jasmine. Let's see a brief introduction about both of them.

Testing

When we are coding, we have to be sure that our code is working as we expect. More than that, when we update our existing code, we have to be 100% sure that the old one is still working. As our website becomes larger, it becomes more difficult to check that all our features are working as we expect. How can we automatize this process? The answer is with testing.

Requirements

  • Fork this repo
  • Clone this repo

Submission

  • Upon completion, run the following commands:

    git add .
    git commit -m "done"
    git push origin master
    
  • Create Pull Request so your TAs can check up your work.

We need to execute our tests so open the file SpecRunner.html with your browser.

In the beginning, you will see all the tests in yellow because the tests we have to implement are commented. (except for one, that throws an error, no worries ๐Ÿ˜‰)

All the tests are located inside the spec folder. Open the koans.js file and uncomment the following line:

it('`var` works as usual, it does not restricts scope', () => {
  if (true) {
    /*You should add your code in here*/
  }
  expect(varX).toBe(true);
});

When we uncomment the line and refresh the SpecRunner.html page, we will see something like that:

image

The primary goal is not to finish all the tests. We want you to understand why each test is failing and how does JavaScript ES6 work in specific scopes.

To do that, the correct workflow is the one used on Test Driven Development(TDD):

  • Uncomment the test
  • Refresh the page to see that the uncommented test is failing
  • Change the code to pass the test
  • Refresh the page to see that the test is passing

:::warning Leave the expect lines unchanged! ๐Ÿ‘€ :::

This process has to be done for each test. Do not uncomment all the tests and launch the app. It will be more difficult for you to see if your code is passing the tests.

Since the Koans includes tests about a lot of the ES6 features, you can keep practicing individually after class.

As we said, this is an excellent way to learn things about a programming language.

Happy coding! โค๏ธ

lab-es6-javascript-koans's People

Contributors

marcospalaciosiii avatar papuarza avatar sandrabosk 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.