Skip to content

Commit ee2c4d1

Browse files
jenmyerssgharms
authored andcommitted
Standardize format and edit content (learn-co-curriculum#1)
* Standardize format and edit content * Incorporate feedback
1 parent 9956ec0 commit ee2c4d1

File tree

1 file changed

+76
-23
lines changed

1 file changed

+76
-23
lines changed

README.md

Lines changed: 76 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,34 @@
1-
# Variables Lab
1+
# JavaScript Variables Lab
2+
3+
## Problem Statement
4+
5+
We've covered a lot of JavaScript concepts, but now it's time to put the concepts in to practice. We'll start with variables.
26

37
## Objectives
8+
49
1. Practice using the `const` and `let` variables in JavaScript
510

611
## Instructions
7-
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.
812

9-
### Tests...
10-
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.
13+
You might notice a few new things in this lesson that we haven't encountered
14+
before. Don't worry, we'll walk you through them.
15+
16+
### Tests
1117

12-
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.
18+
When we want to run an experiment, we need to develop a hypothesis and we need
19+
to test it. In programming, we run tests to verify that programs behave the way
20+
we think they do. Tests help us identify bugs and judge how healthy our
21+
applications are.
22+
23+
We use tests to describe the program's behavior, just as you would in a
24+
professional coding environment, and we also use them as teaching tools. You are
25+
in charge of getting the tests to pass.
1326

1427
### Structure
15-
The structure of this lab — where its files and folders are located — looks roughly like the following:
28+
29+
The structure of this lab — where its files and folders are located — looks
30+
roughly like the following:
31+
1632
```
1733
├── CONTRIBUTING.md
1834
├── LICENSE.md
@@ -24,65 +40,102 @@ The structure of this lab — where its files and folders are located — looks
2440
└── indexTest.js
2541
```
2642

27-
All labs will more or less have the same structure. (And non-lab lessons, for that matter, will still have CONTRIBUTING.md, LICENSE.md, and README.md files.)
43+
All labs will more or less have the same structure. (And non-lab lessons, for
44+
that matter, will still have CONTRIBUTING.md, LICENSE.md, and README.md files.)
45+
46+
### Code Along
2847

29-
### Code-along
30-
For now, open up `index.js` in your text editor. If you're using the Learn IDE, click the blue "Open" button in the top right hand corner of the lesson. If you open up that `js-basics-variables-lab/` directory, you'll see a list of files (along with a `test/` directory). Click `index.js`, and it will open in the editor.
48+
Open up `index.js` in your text editor. If you're using the Learn IDE, click the
49+
blue "Open" button in the top right hand corner of the lesson. If you open up
50+
that `js-basics-variables-lab/` directory, you'll see a list of files (along
51+
with a `test/` directory). Click `index.js`, and it will open in the editor.
3152

3253
In `index.js`, you should see, well, nothing. We'll fix that soon.
3354

34-
Now open up `test/indexTest.js`. Hey, there's something! What's all of this stuff doing?
55+
Now open up `test/indexTest.js`. Hey, there's something! What's all of this
56+
stuff doing?
3557

36-
**Note: The `test/indexTest.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.**
58+
**Note:** The `test/indexTest.js` has great info that we want to look at, but do
59+
not edit this file otherwise you may have extra difficulty passing this lab.
3760

3861
A few lines down in the `test/indexTest.js` file you will see:
62+
3963
```js
4064
describe('index.js', function () {
4165
// there's stuff in here, too
4266
});
4367
```
4468

45-
`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:
69+
`describe` is a function provided by our test library, Mocha, and it's used to
70+
hold our tests. After the word `describe` is information about our tests. Tests
71+
are used as a way to document the behavior of a function to developers. For
72+
example, the next word `describe` is followed by the word `companyName` name.
73+
Here the test is telling us that the tests that come afterwords will be about
74+
`companyName`. Then comes the word `it`, where you see the following:
75+
4676
```js
4777
it('is set as Scuber', function () {
4878
// tests are here
4979
});
5080
```
5181

52-
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:
82+
This is telling us that the `companyName` should be set to `Scuber`. Finally,
83+
filling in the missing part of the `it` code, we see:
84+
5385
```js
5486
it('is set as Scuber', function () {
5587
expect(companyName).to.equal('Scuber');
5688
});
5789
```
5890

59-
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.
91+
This example shows that the test expects `companyName` to equal `Scuber`. That
92+
`expect` and `to.equal` are essentially doing the same thing as `companyName ==
93+
'Scuber'`. In other words, `expect(companyName).to.equal('Scuber')` is running
94+
code that will have this first test pass if `companyName` equals `Scuber` and
95+
fail if it does not.
96+
97+
Don't worry too much yet if it's hard to understand what is happening inside of
98+
the `test/indexTest.js` file. But it's a good idea to open up the file, and
99+
gather the information that you can. We will also provide instructions in the
100+
`README.md` file that will allow you to complete the lab.
60101

61-
Don't worry too much yet if it's hard to understand what is happening inside of the `test/indexTest.js` file. But it's a good idea to open up the file, and gather the information that you can. We will also provide Instructions in the `README.md` file that will allow you to complete the lab (as we do in this lab below).
102+
## Running the Tests
62103

63-
## Running the tests
64-
To run the tests, simply type `learn` in the terminal part of the Learn IDE. (The terminal is the part below where you've been coding.)
104+
To run the tests, type `learn` in the terminal part of the Learn IDE.
105+
(The terminal is the part below where you've been coding.)
65106

66-
Running the `learn` command will open up a new tab on your browser, showing the current status of the tests. For the moment, all of the tests fail. Let's figure out how to get one of them passing! (The rest will be up to you.)
107+
Running the `learn` command will open up a new tab on your browser, showing the
108+
current status of the tests. For the moment, all of the tests fail. Let's figure
109+
out how to get one of them passing! (The rest will be up to you.)
110+
111+
To get our first test to pass, we can open up our `index.js` file, and write the
112+
following:
67113

68-
To get our first test to pass, we can open up our `index.js` file, and write the following:
69114
```js
70115
let companyName = 'Scuber';
71116
```
72117

73-
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...
118+
Great, our first test is now passing. However, the second test that is also about
119+
`companyName` is not yet passing. It's not passing because, it expects a change to
120+
`companyName` to throw a `TypeError`. It sounds like it wants `companyName` to
121+
be declared using a different keyword than the `let` keyword - it needs a
122+
keyword that is used for variables that can't be changed...
123+
124+
Continue to work through the problems below. Keep in mind the general workflow
125+
for a lab:
74126

75-
Ok, so we'll let you work through the problems below. But in summary here is your workflow for a lab:
76127
1. Run `learn`.
77128
2. Read the errors; vocalize what they're asking you to do.
78129
3. Write code; repeat steps 1 and 2 often until a test passes.
79130
4. Repeat as needed for further tests.
80131
5. Run `learn submit` when finished!
81132

82-
## Working through the problems
133+
## Working Through the Problems
134+
83135
If you open up `test/indexTest.js`, you will see the tasks in front of you:
136+
84137
+ `companyName` - Inside the `test/indexTest.js` file, 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 afterwards, 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.
85-
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 is confusing. Just know that the code attempts to change `companyName` to a different value, and that this reassignment should throw an error. So you need to make sure that you are using the correct type of variable declaration such that attempting to reassign the variable throws an error.
138+
+ 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 is confusing. Just know that the code attempts to change `companyName` to a different value, and that this reassignment should throw an error. So you need to make sure that you are using the correct type of variable declaration such that attempting to reassign the variable throws an error.
86139
+ `mostProfitableNeighborhood` - Here we need to declare another variable, `mostProfitableNeighborhood` and assign to it the string `'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 type of variable declaration such that assigning a new value to `mostProfitableNeighborhood` doesn't throw an error.
87140
+ `companyCeo` - Here, we are getting more practice with declaring variables. Once again, a reassignment should not throw an error.
88141

0 commit comments

Comments
 (0)