Skip to content

Commit e1b6b60

Browse files
committed
Merge pull request liammclennan#21 from SaintGimp/master
Fixes and clarifications from a newbie
2 parents 6fcf044 + 3fd1795 commit e1b6b60

File tree

6 files changed

+28
-27
lines changed

6 files changed

+28
-27
lines changed

topics/about_arrays.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ test("stack methods", function() {
2929
stack.push("first");
3030
stack.push("second");
3131

32-
equals(stack.pop(), __, 'what will be the first value poped off the stack?');
33-
equals(stack.pop(), __, 'what will be the second value poped off the stack?');
32+
equals(stack.pop(), __, 'what will be the first value popped off the stack?');
33+
equals(stack.pop(), __, 'what will be the second value popped off the stack?');
3434
});

topics/about_functions_and_closure.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ test("arguments array", function() {
3737
var total = 0;
3838
for(var i = 0; i < arguments.length; i++) {
3939
// complete the implementation of this method so that it returns the sum of its arguments
40+
// __
4041
}
4142
// __
4243
};

topics/about_prototypal_inheritance.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ test("calling functions added to a prototype after an object was created", funct
3434
Mammal.prototype.numberOfLettersInName = function() {
3535
return this.name.length;
3636
};
37-
// for the following statement asks the paul object to call a function that was added to the Mammal prototype after paul was constructed.
37+
// the following statement asks the paul object to call a function that was added
38+
// to the Mammal prototype after paul was constructed.
3839
equals(paul.numberOfLettersInName(), __, "how long is Paul's name?");
3940
});
4041

topics/about_prototype_chain.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ child.b = 2;
2626
* ---------------------- ---- ---- ----
2727
* */
2828

29-
test("Is there an 'a' and 'b' own property on childObj?", function () {
29+
test("Is there an 'a' and 'b' own property on child?", function () {
30+
equals(child.hasOwnProperty('a'), __, 'child.hasOwnProperty(\'a\')?');
31+
equals(child.hasOwnProperty('b'), __, 'child.hasOwnProperty(\'b\')?');
32+
});
33+
34+
test("Is there an 'a' and 'b' property on child?", function () {
3035
equals(child.a, __, 'what is \'a\' value?');
3136
equals(child.b, __, 'what is \'b\' value?');
3237
});
@@ -37,22 +42,22 @@ test("If 'b' was removed, whats b value?", function () {
3742
});
3843

3944

40-
// Is there a 'c' own property on childObj? No, check its prototype
41-
// Is there a 'c' own property on childObj.[[Prototype]]? Yes, its value is...
42-
test("Is there a 'c' own property on childObj.[[Prototype]]?", function () {
43-
equals(child.hasOwnProperty('c'), __, 'childObj.hasOwnProperty(\'c\')?');
45+
test("Is there a 'c' own property on child?", function () {
46+
equals(child.hasOwnProperty('c'), __, 'child.hasOwnProperty(\'c\')?');
4447
});
4548

46-
test("Is there a 'c' own property on childObj.[[Prototype]]?", function () {
47-
equals(child.c, __, 'childObj.c?');
49+
// Is there a 'c' own property on child? No, check its prototype
50+
// Is there a 'c' own property on child.[[Prototype]]? Yes, its value is...
51+
test("Is there a 'c' property on child?", function () {
52+
equals(child.c, __, 'what is the value of child.c?');
4853
});
4954

5055

51-
// Is there a 'd' own property on childObj? No, check its prototype
52-
// Is there a 'd' own property on childObj.[[Prototype]]? No, check it prototype
53-
// childObj.[[Prototype]].[[Prototype]] is null, stop searching, no property found, return...
54-
test("Is there an 'd' own property on childObj?", function () {
55-
equals(child.d, __, 'what is the value of childObj.d?');
56+
// Is there a 'd' own property on child? No, check its prototype
57+
// Is there a 'd' own property on child.[[Prototype]]? No, check it prototype
58+
// child.[[Prototype]].[[Prototype]] is null, stop searching, no property found, return...
59+
test("Is there an 'd' property on child?", function () {
60+
equals(child.d, __, 'what is the value of child.d?');
5661
});
5762

5863

topics/about_scope.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,5 @@ test("variables declared inside of a function", function() {
1818
})();
1919

2020
equals(outerVariable, __, 'is outerVariable defined in this scope?');
21-
var isInnerVariableDefined = true;
22-
try {
23-
innerVariable
24-
} catch(e) {
25-
isInnerVariableDefined = false;
26-
}
27-
equals(isInnerVariableDefined, __, 'is innerVariable defined in this scope?');
21+
equals(typeof(innerVariable), "undefined", 'is innerVariable defined in this scope?');
2822
});

topics/about_this.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,25 @@ test("'this' inside a method", function () {
1212

1313
test("'this' on unattached function", function () {
1414
var person = {
15-
handle: 'bob',
15+
name: 'bob',
1616
intro: function () {
17-
return "Hello, my name is " + this.handle;
17+
return "Hello, my name is " + this.name;
1818
}
1919
}
2020

2121
var alias = person.intro;
2222

23-
// if the function called as an object property 'this' is the global context
23+
// if the function is not called as an object property 'this' is the global context
2424
// (window in a browser)
2525
window.__ = 'Peter';
2626
equals("Hello, my name is Peter", alias());
2727
});
2828

2929
test("'this' set explicitly", function () {
3030
var person = {
31-
handle: 'bob',
31+
name: 'bob',
3232
intro: function () {
33-
return "Hello, my name is " + this.handle;
33+
return "Hello, my name is " + this.name;
3434
}
3535
}
3636

0 commit comments

Comments
 (0)