forked from thinkb4/a-walk-in-javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscope.test.js
54 lines (31 loc) · 947 Bytes
/
scope.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
54
describe('DAY 6: Test Scope', () => {
it(`n to be available outside of the block scope`, () => {
{
// change the declaration statement to accomplish the task
let n = 5;
}
expect(n).toBe(5);
});
it(`outer n to be 5
inner IIFE n var to be 4 (hint: add the missing code)`, () => {
let n = 5;
(function () {
expect(n).toBe(4);
}());
expect(n).toBe(5);
});
it(`inner most IIFE to have access to the outer most n var (hint: change the expect statement)`, () => {
let n = 5;
(function () {
(function () {
(function () {
(function () {
(function () {
expect(n).not.toBe(5);
}());
}());
}());
}());
}());
});
});