-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path01_variables.test.js
53 lines (43 loc) · 1.05 KB
/
01_variables.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
describe("About variables", () => {
it("should understand VAR", () => {
var x = 5;
var x = 6;
expect(x).toBe(6); // was expect(x).toBe(5);
});
it("should understand the difference between LET and VAR", () => {
var x = 6;
x = 5; // was let x = 5;
expect(x).toBe(5);
});
it("should understand LET", () => {
let x = 5;
x = 6; // was let x = 6;
expect(x).toBe(6);
});
it("should understand LET scoping", () => {
let x = 5;
function foo() {
let x = 20;
return x;
}
expect(x).toBe(5); // was expect(x).toBe(20);
});
it("should understand CONST - scalar values", () => {
const x = 5;
// was x = 'foo';
expect(x).toBe(5);
});
it("should understand CONST - assignment", () => {
const x = 5; // was const x;
// was x = 5;
expect(x).toBe(5);
});
it("should understand CONST - objects", () => {
const person = {
name: "Linus",
age: 42
};
person.lastname = "torvalds"; // was nothing
expect(person.lastname).toBe("torvalds");
});
});