├── README.md ├── SpecRunner.html ├── functions.js └── lib ├── chai └── chai.js └── mocha ├── mocha.css └── mocha.js /README.md: -------------------------------------------------------------------------------- 1 | # Hack Reactor: Functions & Scopes Workshop 2 | 3 | You're here to solidify your understanding of Functions & Scopes in JavaScript. 4 | 5 | *IMPORTANT*: Completion of this workshop is no guarantee of admission into the Hack Reactor immersive program, nor does it have any influence in the admissions process. 6 | 7 | ## Prerequisites 8 | 9 | It is recommended that students understand JavaScript variables, if/else statements, loops, objects, arrays and functions prior to this course; however it is not required. Students should have approximately 2 months of experience with JavaScript and programming. 10 | 11 | ## Textbook 12 | 13 | No textbook is required for this workshop. All materials are included in this GitHub repo. 14 | 15 | ## Technical requirements 16 | 17 | Laptop, Google Chrome browser and a text editor. If you do not have a text editor, we recommend Sublime Text, Atom or Visual Studio Code. 18 | 19 | # How to use this repository 20 | 21 | #### It is your mission to go through the function.js file and change all the `'???'` in such a way that all the tests pass true. 22 | 23 | ### Let's get started... 24 | 25 | Run the specrunner.html file in a browser. This document shows one passed test and a series of failing tests. 26 | 27 | The **functions.js** folder holds all the failing tests that are being displayed in **SpecRunner.html**. You will be editing this file and using the **SpecRunner.html** to check your progress on making these tests pass. This is just a javascript file so you can use console.log to help debug and inspect these functions. 28 | 29 | A test block starts with an `it` function. The `it` function takes two arguments. The first one is a statement describing the rule addressed by the test. The second is a function that will either evaluate to true or false using the `expect` function. The expect statement (`expect(ACTUAL === 'inner').to.be.true;`) will evaluate if the statement between the parens `ACTUAL === 'inner'` is true. You can almost read it like plain English. The expect statement below "expects that the variable ACTUAL equals the value 'inner' to be true". 30 | 31 | #### Failing Test Example 32 | 33 | it('a function has access to its own local scope variables', 34 | 35 | function () { 36 | var fn = function () { 37 | var name = 'inner'; 38 | ACTUAL = name; 39 | }; 40 | fn(); 41 | expect(ACTUAL === '???').to.be.true; 42 | //change '???' to what ACTUAL evaluates to. 43 | }); 44 | 45 | #### Passing Test Example 46 | 47 | it('a function has access to its own local scope variables', 48 | 49 | function () { 50 | var fn = function () { 51 | var name = 'inner'; 52 | ACTUAL = name; 53 | }; 54 | fn(); 55 | expect(ACTUAL === 'inner').to.be.true; 56 | //changed '???' to 'inner' 57 | //(because we assigned ACTUAL, a global variable to name inside fn) 58 | }); 59 | 60 | ### Don't forget.. 61 | You should throroughly read all of code in front of you and aim to understand line-by-line what is happening. 62 | -------------------------------------------------------------------------------- /SpecRunner.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 5 |