forked from liammclennan/JavaScript-Koans
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11_about_scope.js
More file actions
25 lines (21 loc) · 829 Bytes
/
11_about_scope.js
File metadata and controls
25 lines (21 loc) · 829 Bytes
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
describe("About Scope (topics/11_about_scope.js)", () => {
thisIsAGlobalVariable = 77;
expect("global variables", function () {
equal(
__,
thisIsAGlobalVariable,
"is thisIsAGlobalVariable defined in this scope?"
);
});
expect("variables declared inside of a function", function () {
let outerVariable = "outer";
// this is a self-invoking function. Notice that it calls itself at the end ().
(function () {
let innerVariable = "inner";
expect(__).toBe(outerVariable, "is outerVariable defined in this scope?");
expect(__).toBe(innerVariable, "is innerVariable defined in this scope?");
})();
expect(__, outerVariable, "is outerVariable defined in this scope?");
expect(__, typeof innerVariable, "is innerVariable defined in this scope?");
});
});