Skip to content

Commit c37410e

Browse files
committed
Update lab files
1 parent 8db2d8d commit c37410e

File tree

8 files changed

+51
-69
lines changed

8 files changed

+51
-69
lines changed

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ jspm_packages/
3333
# macOS system directory file
3434
.DS_Store
3535

36-
# Learn.co files
37-
.results.json
38-
learn.auth.data.json
36+
# Package lockfiles
37+
package-lock.json
38+
yarn.lock

.learn

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
tags:
2-
- learn.co
3-
- flatiron school
4-
- javascript
52
- variables
63
- let
74
- const

README.md

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
1-
JavaScript Variables Lab
2-
---
1+
# Variables Lab
32

43
## Objectives
5-
64
- Practice using the `const` and `let` variables in JavaScript
75

86
## Instructions
9-
107
Ok, so this is your first lab. You'll notice a few new things in this lesson that we haven't encountered before. Don't worry, we'll walk you through them.
118

129
### Tests...
13-
1410
The first new thing you'll notice is tests. When we want to run an experiment, we need to develop a hypothesis and we need to test it. In programming, we run tests serve as our experiment to verify that programs behave the way we think they do. Tests help us identify bugs, and they give us a sense of the health of our applications.
1511

1612
Here, we use tests as teaching tools. Just like in a normal coding environment, we use tests to describe the program's behavior. You are in charge of getting the tests to pass.
1713

1814
### Structure
19-
2015
The structure of this lab — where its files and folders are located — looks roughly like the following:
21-
2216
```
2317
├── CONTRIBUTING.md
2418
├── LICENSE.md
@@ -33,7 +27,6 @@ The structure of this lab — where its files and folders are located — looks
3327
All labs will more or less have the same structure. (And READMEs, for that matter, will still have CONTRIBUTING.md, LICENSE.md, and README.md files.)
3428

3529
### Code-along
36-
3730
For now, open up `index.js` in your text editor. If you're using the Learn IDE, click the "Open" button in the top right hand corner of the lesson. If you open up that "js-basic-variables-lab" folder, you'll see a list of files (along with a test/ directory). Click `index.js`, and it will open in the editor.
3831

3932
In `index.js`, you should see, well, nothing. We'll fix that soon.
@@ -43,27 +36,26 @@ Now open up `test/index-test.js`. Hey, there's something! What's all of this stu
4336
**Note: The `test/index-test.js` has great info that we want to look at, but do not edit this file otherwise you may have extra difficulty passing this lab.**
4437

4538
A few lines down in the `test/index-test.js` file you will see:
46-
4739
```js
48-
describe('Using Variables', () => {
40+
describe('index.js', function () {
4941
// there's stuff in here, too
50-
})
42+
});
5143
```
5244

5345
`describe` is a function provided by our test library, Mocha. The word is basically used to hold our tests. You can see that after the word `describe` is a description about our tests. Tests are used as a way to document the behavior of a function to developers, and you can see that examples of that after the words `describe`. For example, the next word `describe` is followed by the word `companyName` name. Here the test is telling us that the tests that come after words will be about `companyName`. Then comes the word `it`, where you see the following:
5446

5547
```js
56-
it('is set as Scuber', () => {
48+
it('is set as Scuber', function () {
5749
// tests are here
58-
})
50+
});
5951
```
6052

6153
So this is telling us that the `companyName` should be set to `Scuber`. Finally, filling in the missing part of the `it` code, we see:
6254

6355
```js
64-
it('is set as Scuber', () => {
65-
expect(companyName).to.equal('Scuber')
66-
})
56+
it('is set as Scuber', function () {
57+
expect(companyName).to.equal('Scuber');
58+
});
6759
```
6860

6961
Here, we can see that it expects `companyName` to equal `Scuber`. That `expect` and `to.equal` are essentially doing the same thing as `companyName == 'Scuber'`. In other words, `expect(companyName).to.equal('Scuber')` is running code that will have this first test pass if `companyName` equals `Scuber` and fail if it does not.
@@ -79,40 +71,31 @@ Running the `learn` command will open up a new tab on your browser, showing the
7971
To get our first test to pass, we can open up our `index.js` file, and write the following:
8072

8173
```js
82-
83-
let companyName = 'Scuber'
84-
74+
let companyName = 'Scuber';
8575
```
8676

87-
Great, our first test is now passing. Except the second test is also about `companyName` and it is not. It's not passing because, it expects a change to `companyName` to throw a `TypeError`. It sounds like it wants `companyName` to be declared using a different keyword than the `let` keyword - it needs a keyword that is used for variables that can't be changed...
77+
Great, our first test is now passing. Except the second test is also about `companyName` and it is not. It's not passing because, it expects a change to `companyName` to throw a `TypeError`. It sounds like it wants `companyName` to be declared using a different keyword than the `let` keyword - it needs a keyword that is used for variables that can't be changed...
8878

8979
Ok, so we'll let you work through the problems below. But in summary here is your workflow for a lab:
9080

9181
1. Run `learn`.
92-
9382
2. Read the errors; vocalize what they're asking you to do.
94-
9583
3. Write code; repeat steps 1 and 2 often until a test passes.
96-
9784
4. Repeat as needed for further tests.
98-
9985
5. Run `learn submit` when finished!
10086

101-
10287
## Working Through The Problems
103-
10488
If you open up `test/indexTest.js`, you will see the tasks in front of you.
10589

106-
+ `companyName` - Inside the `test/indexTest`, look inside of the word `describe` where the tests are trying to indicate that this test is describing the `companyName` variable. The `it` word that comes afterwords, tells us the features of `companyName`. In the first `it` function call, it says that `it` (companyName) `is set as Scuber`. In the next line, you can see that the test checks to make sure this occurs by seeing if `companyName` equals `Scuber`. So this means that you need to go to your `index.js` file and declare a variable named `companyName` and set it equal to `Scuber`. Once you do that, if `learn` is running, you will see the first test in this lab as passing.
90+
+ `companyName` - Inside the `test/indexTest`, look inside of the word `describe` where the tests are trying to indicate that this test is describing the `companyName` variable. The `it` word that comes afterwords, tells us the features of `companyName`. In the first `it` function call, it says that `it` (companyName) `is set as Scuber`. In the next line, you can see that the test checks to make sure this occurs by seeing if `companyName` equals `Scuber`. So this means that you need to go to your `index.js` file and declare a variable named `companyName` and set it equal to `Scuber`. Once you do that, if `learn` is running, you will see the first test in this lab as passing.
10791

10892
In the next `it` function call, we are still describing `companyName`. This time, it says it `raises error if the companyName is changed`. The next line of code tests this. It's ok if some of the code in that line are confusing. Just know that the code attempts to change `companyName` to a different value, and that this reassignment to throw an error. So you need to make sure that you are using the correct variable type such that reassigning the variable would throw an error.
10993

11094
+ `mostProfitableNeighborhood` - Here we need to declare another variable, `mostProfitableNeighborhood` and assign it to `Chelsea`. In the next `it` function call, you can see that our tests ensure that `mostProfitableNeighborhood` does not throw an error when reassigned. So you need to make sure that you are using the correct variable type such that reassigning the `mostProfitableNeighborhood` would not throw an error.
11195

112-
+ `companyCeo` - Here, we are getting more practice with declaring variables. Once again, a reassignment should not throw an error.
96+
+ `companyCeo` - Here, we are getting more practice with declaring variables. Once again, a reassignment should not throw an error.
11397

11498
## Resources
115-
11699
- [MDN: Let](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let)
117100
- [MDN: Const](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const)
118101

index.html

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
<!-- Include Chai as the matcher library. -->
2222
<script src="node_modules/chai/chai.js"></script>
2323

24-
25-
2624
<!-- Include the student's JavaScript file. -->
2725
<script src="index.js"></script>
2826

@@ -31,8 +29,5 @@
3129

3230
<!-- Include Flatiron School's test runner to push results to Learn. -->
3331
<script src="node_modules/learn-browser/learnBrowser.min.js"></script>
34-
35-
<!-- Run the test suite automatically when the page loads. -->
36-
<script>LearnBrowser.test();</script>
3732
</body>
3833
</html>

index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1+
const companyName = 'Scuber';
12

3+
let mostProfitableNeighborhood = 'Chelsea';
4+
5+
let companyCeo = 'Susan Smith';

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
{
22
"name": "js-variables-lab",
3-
"version": "0.2.0",
3+
"version": "0.1.0",
44
"description": "JavaScript Variables Lab for Learn.co",
55
"main": "index.js",
6+
"scripts": {
7+
"postinstall": "gem install learn-co",
8+
"test": "node_modules/browser-sync/bin/browser-sync.js start --config node_modules/learn-browser/bs-config.js"
9+
},
610
"repository": {
711
"type": "git",
812
"url": "git+ssh://git@github.com/learn-co-curriculum/js-basics-variables-lab.git"
@@ -23,6 +27,6 @@
2327
},
2428
"homepage": "https://github.com/learn-co-curriculum/js-basics-variables-lab#readme",
2529
"devDependencies": {
26-
"learn-browser": "^0.1.6"
30+
"learn-browser": "^0.1.13"
2731
}
2832
}

test/indexTest.js

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
const expect = chai.expect;
22

3-
describe('Using Variables', function() {
4-
describe('companyName', function() {
5-
it('is set as Scuber', () => {
6-
expect(companyName).to.equal('Scuber')
7-
})
3+
describe('index.js', function () {
4+
describe('companyName', function () {
5+
it('is set as Scuber', function () {
6+
expect(companyName).to.equal('Scuber');
7+
});
88

9-
it('raises error if the companyName is changed', () => {
10-
expect(() => { companyName = 'specialCompany'}).to.throw(TypeError)
11-
})
12-
})
9+
it('raises error if the companyName is changed', function () {
10+
expect(function () { companyName = 'specialCompany' }).to.throw(TypeError);
11+
});
12+
});
1313

14-
describe('mostProfitableNeighborhood', function() {
15-
it('is declared as equal to Chelsea', function() {
16-
expect(mostProfitableNeighborhood).to.equal('Chelsea')
17-
})
14+
describe('mostProfitableNeighborhood', function () {
15+
it('is declared as equal to Chelsea', function () {
16+
expect(mostProfitableNeighborhood).to.equal('Chelsea');
17+
});
1818

19-
it('does not raise error if the mostProfitableNeighborhood is changed', function(){
20-
expect(() => { mostProfitableNeighborhood = 'Upper West Side'}).to.not.throw(TypeError)
21-
})
22-
})
19+
it('does not raise error if the mostProfitableNeighborhood is changed', function () {
20+
expect(function () { mostProfitableNeighborhood = 'Upper West Side' }).to.not.throw(TypeError);
21+
});
22+
});
2323

24-
describe('companyCeo', function() {
25-
it('is declared as equal to Susan Smith', function() {
26-
expect(companyCeo).to.equal('Susan Smith')
27-
})
24+
describe('companyCeo', function () {
25+
it('is declared as equal to Susan Smith', function () {
26+
expect(companyCeo).to.equal('Susan Smith');
27+
});
2828

29-
it('does not raise error if the companyCeo is changed', function(){
30-
expect(() => { companyCeo = 'Lauren Hart'}).to.not.throw(TypeError)
31-
})
32-
})
33-
})
29+
it('does not raise error if the companyCeo is changed', function () {
30+
expect(function () { companyCeo = 'Lauren Hart' }).to.not.throw(TypeError);
31+
});
32+
});
33+
});

test/sinon-test-utils.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)