GithubHelp home page GithubHelp logo

lab-es6-javascript-koans's Introduction

Ironhack Logo

JS | Koans Lab ES6

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, and are paradoxical riddles or stories 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 work 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. We have introduced here two new concepts: test 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

We need to execute our tests. First of all, fork and clone this repo into your Github account. Once you are done, 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 througs an error, no worries ๐Ÿ˜‰)

image

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 de 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 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.

Pair Programing

Since the Koans includes tests about a lot of the ES6 features, you will use the same exercise for Pair Programming and Daily Exercise.

The first 46 tests corresponds to the Pair Programming, and the rest are for the Daily Exercise. Inside the koans.js you will find a flag to indicate where the Daily Exercise begins:

/*********************************
********* DAILY EXERCISE *********
**********************************/

Do not worry if you don't reach the flag during the Pair Programming, you can continue later! ๐Ÿ˜‰

As we said, this is an excellent way to learn things about a programming language. Good luck to all of you :)

lab-es6-javascript-koans's People

Contributors

papuarza 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.