Skip to content

Commit c77e0d8

Browse files
committed
in process
1 parent 6fcf044 commit c77e0d8

17 files changed

Lines changed: 103 additions & 101 deletions

topics/about_arrays.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,32 @@ module("About Arrays (topics/about_arrays.js)");
33

44
test("array literal syntax and indexing", function() {
55
var favouriteThings = ["cellar door", 42, true]; // note that array elements do not have to be of the same type
6-
equals(favouriteThings[0], __, 'what is in the first position of the array?');
7-
equals(favouriteThings[1], __, 'what is in the second position of the array?');
8-
equals(favouriteThings[2], __, 'what is in the third position of the array?');
6+
equals(favouriteThings[0], "cellar door", 'what is in the first position of the array?');
7+
equals(favouriteThings[1], 42, 'what is in the second position of the array?');
8+
equals(favouriteThings[2], true, 'what is in the third position of the array?');
99
});
1010

1111
test("array type", function() {
12-
equals(typeof([]), __, 'what is the type of an array?');
12+
equals(typeof([]), "object", 'what is the type of an array?');
1313
});
1414

1515
test("length", function() {
1616
var collection = ['a','b','c'];
17-
equals(collection.length, __, 'what is the length of the collection array?');
17+
equals(collection.length, 3, 'what is the length of the collection array?');
1818
});
1919

2020
test("splice", function() {
2121
var daysOfWeek = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
22-
var workingWeek = daysOfWeek.splice(__, __);
23-
ok(workingWeek.equalTo([__]), 'what is the value of workingWeek?');
24-
ok(daysOfWeek.equalTo([__]), 'what is the value of daysOfWeek?');
22+
var workingWeek = daysOfWeek.splice(0, 5);
23+
ok(workingWeek.equalTo(['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday']), 'what is the value of workingWeek?');
24+
ok(daysOfWeek.equalTo(['Saturday', 'Sunday']), 'what is the value of daysOfWeek?');
2525
});
2626

2727
test("stack methods", function() {
2828
var stack = [];
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(), "second", 'what will be the first value poped off the stack?');
33+
equals(stack.pop(), "first", 'what will be the second value poped off the stack?');
3434
});

topics/about_asserts.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
module("About Asserts (topics/about_asserts.js)");
33

44
test("ok", function() {
5-
ok(__, 'what will satisfy the ok assertion?');
5+
ok(true, 'what will satisfy the ok assertion?');
66
});
77

88
test("not", function() {
9-
not(__, 'what is a false value?');
9+
not(false, 'what is a false value?');
1010
});
1111

1212
test("equals", function() {
13-
equals(1+1, __, 'what will satisfy the equals assertion?');
13+
equals(1+1, 2, 'what will satisfy the equals assertion?');
1414
});

topics/about_assignment.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
module("About Assignment (topics/about_assignment.js)");
33

44
test("local variables", function() {
5-
var temp = __;
5+
var temp = 1;
66
equals(1, temp, "Assign a value to the variable temp");
77
});
88

99
test("global variables", function() {
1010
temp = 1;
11-
equals(temp, window.__, 'global variables are assigned to the window object');
11+
equals(temp, window.temp, 'global variables are assigned to the window object');
1212
});

topics/about_control_structures.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,38 @@ test("if", function() {
55
if (2 > 0) {
66
isPositive = true;
77
}
8-
equals(isPositive, __, 'what is the value of isPositive?');
8+
equals(isPositive, true, 'what is the value of isPositive?');
99
});
1010

1111
test("for", function() {
1212
var counter = 10;
1313
for (var i = 1; i <= 3; i++) {
1414
counter = counter + i;
1515
}
16-
equals(counter, __, 'what is the value of counter?');
16+
equals(counter, 16, 'what is the value of counter?');
1717
});
1818

1919
test("for in", function() {
2020
// this syntax will be explained in about objects
2121
var person = {
2222
name: "Amory Blaine",
2323
age: 102
24+
2425
};
2526
var result = "";
2627
// for in enumerates the property names of an object
2728
for (property_name in person) {
2829
result = result + property_name;
2930
};
30-
equals(result, __, 'what is the value of result?');
31+
equals(result, "nameage", 'what is the value of result?');
3132
});
3233

3334
test("ternary operator", function() {
3435
var fruit = true ? "apple" : "orange";
35-
equals(fruit, __, 'what is the value of fruit?');
36+
equals(fruit, "apple", 'what is the value of fruit?');
3637

3738
fruit = false ? "apple" : "orange";
38-
equals(fruit, __, 'now what is the value of fruit?');
39+
equals(fruit, "orange", 'now what is the value of fruit?');
3940
});
4041

4142
test("switch", function() {
@@ -48,7 +49,7 @@ test("switch", function() {
4849
result = 2;
4950
break;
5051
}
51-
equals(result, __, 'what is the value of result?');
52+
equals(result, 2, 'what is the value of result?');
5253
});
5354

5455
test("switch default case", function() {
@@ -64,10 +65,10 @@ test("switch default case", function() {
6465
result = "Merry";
6566
break;
6667
}
67-
equals(result, __, 'what is the value of result?');
68+
equals(result, "Merry", 'what is the value of result?');
6869
});
6970

7071
test("null coalescing", function() {
7172
var result = null || "a value";
72-
equals(result, __, 'what is the value of result?');
73+
equals(result, "a value", 'what is the value of result?');
7374
});

topics/about_equality.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22
module("About Equality (topics/about_equality.js)");
33

44
test("numeric equality", function() {
5-
equals(3 + __, 7, 'hmmmm?');
5+
equals(3 + 4, 7, 'hmmmm?');
66
});
77

88
test("string equality", function() {
9-
equals("3" + __, "37", "concatenate the strings");
9+
equals("3" + "7", "37", "concatenate the strings");
1010
});
1111

1212
test("equality without type coercion", function() {
13-
ok(3 === __, 'what is exactly equal to 3?');
13+
ok(3 === 3, 'what is exactly equal to 3?');
1414
});
1515

1616
test("equality with type coercion", function() {
17-
ok(3 == "__", 'what string is equal to 3, with type coercion?');
17+
ok(3 == "3", 'what string is equal to 3, with type coercion?');
1818
});
1919

2020
test("string literals", function() {
21-
equals("frankenstein", '__', "quote types are interchangable, but must match.");
21+
equals("frankenstein", 'frankenstein', "quote types are interchangable, but must match.");
2222
});

topics/about_functions_and_closure.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ test("defining functions directly", function() {
77
result = "b";
88
};
99
changeResult();
10-
equals(result, __, 'what is the value of result?');
10+
equals(result, "b", 'what is the value of result?');
1111
});
1212

1313
test("assigning functions to variables", function() {
1414
var triple = function(input) {
1515
return input * 3;
1616
};
17-
equals(triple(4), __, 'what is triple 4?');
17+
equals(triple(4), 12, 'what is triple 4?');
1818
});
1919

2020
test("self invoking functions", function() {
@@ -23,22 +23,23 @@ test("self invoking functions", function() {
2323
// self invoking functions are used to provide scoping and to alias variables
2424
(function(pv) {
2525
var secretValue = "password";
26-
equals(pv, __, 'what is the value of pv?');
27-
equals(typeof(secretValue), "__", "is secretValue available in this context?");
28-
equals(typeof(publicValue), "__", "is publicValue available in this context?");
26+
equals(pv, "shared", 'what is the value of pv?');
27+
equals(typeof(secretValue), "string", "is secretValue available in this context?");
28+
equals(typeof(publicValue), "string", "is publicValue available in this context?");
2929
})(publicValue);
3030

31-
equals(typeof(secretValue), "__", "is secretValue available in this context?");
32-
equals(typeof(publicValue), "__", "is publicValue available in this context?");
31+
equals(typeof(secretValue), "undefined", "is secretValue available in this context?");
32+
equals(typeof(publicValue), "string", "is publicValue available in this context?");
3333
});
3434

3535
test("arguments array", function() {
3636
var add = function() {
3737
var total = 0;
3838
for(var i = 0; i < arguments.length; i++) {
39-
// complete the implementation of this method so that it returns the sum of its arguments
39+
total += arguments[i] // complete the implementation of this method so that it returns the sum of its arguments
4040
}
41-
// __
41+
return total;
42+
4243
};
4344

4445
equals(add(1,2,3,4,5), 15, "add 1,2,3,4,5");
@@ -56,7 +57,7 @@ test("using call to invoke function",function(){
5657
//function, and the arguments to be sent to the function,multiple arguments are separated by commas.
5758
var result = invokee.call("I am this!", "Where did it come from?");
5859

59-
equals(result,__,"what will the value of invokee's this be?");
60+
equals(result,"I am this!Where did it come from?","what will the value of invokee's this be?");
6061
});
6162

6263
test("using apply to invoke function",function(){
@@ -69,6 +70,6 @@ test("using apply to invoke function",function(){
6970
//function and and array of arguments to be passed into the called function.
7071
var result = invokee.apply("I am this!", ["I am arg1","I am arg2"]);
7172

72-
equals(result,__,"what will the value of invokee's this be?");
73+
equals(result,"I am this!I am arg1I am arg2","what will the value of invokee's this be?");
7374
});
7475

topics/about_numbers.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ module("About Numbers (topics/about_numbers.js)");
44
test("types", function() {
55
var typeOfIntegers = typeof(6);
66
var typeOfFloats = typeof(3.14159);
7-
equals(typeOfIntegers === typeOfFloats, __, 'are ints and floats the same type?');
8-
equals(typeOfIntegers, __, 'what is the javascript numeric type?');
9-
equals(1.0, __, 'what is a integer number equivalent to 1.0?');
7+
equals(typeOfIntegers === typeOfFloats, true, 'are ints and floats the same type?');
8+
equals(typeOfIntegers, "number", 'what is the javascript numeric type?');
9+
equals(1.0, "1", 'what is a integer number equivalent to 1.0?');
1010
});
1111

1212
test("NaN", function() {
1313
var resultOfFailedOperations = 7/'apple';
14-
equals(isNaN(resultOfFailedOperations), __, 'what will satisfy the equals assertion?');
15-
equals(resultOfFailedOperations == NaN, __, 'is NaN == NaN?');
14+
equals(isNaN(resultOfFailedOperations), true, 'what will satisfy the equals assertion?');
15+
equals(resultOfFailedOperations == NaN, false, 'is NaN == NaN?');
1616
});

topics/about_objects.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,30 @@ module("About Objects (topics/about_objects.js)");
33

44
test("object type", function() {
55
var empty_object = {};
6-
equals(typeof(empty_object), __, 'what is the type of an object?');
6+
equals(typeof(empty_object), "object", 'what is the type of an object?');
77
});
88

99
test("object literal notation", function() {
1010
var person = {
11-
__:__,
12-
__:__
11+
name:"Amory Blaine",
12+
age:"102"
1313
};
1414
equals(person.name, "Amory Blaine", 'what is the person\'s name?');
1515
equals(person.age, 102, 'what is the person\'s age?');
1616
});
1717

1818
test("dynamically adding properties", function() {
1919
var person = {};
20-
person.__ = "Amory Blaine";
21-
person.__ = 102;
20+
person.name = "Amory Blaine";
21+
person.age = 102;
2222
equals(person.name, "Amory Blaine", 'what is the person\'s name?');
2323
equals(person.age, 102, 'what is the person\'s age?');
2424
});
2525

2626
test("adding properties from strings", function() {
2727
var person = {};
28-
person["__"] = "Amory Blaine";
29-
person["__"] = 102;
28+
person["name"] = "Amory Blaine";
29+
person["age"] = 102;
3030
equals(person.name, "Amory Blaine", 'what is the person\'s name?');
3131
equals(person.age, 102, 'what is the person\'s age?');
3232
});
@@ -36,7 +36,7 @@ test("adding functions", function() {
3636
name: "Amory Blaine",
3737
age: 102,
3838
toString: function() {
39-
return __; // HINT: use the 'this' keyword to refer to the person object.
39+
return this person; // HINT: use the 'this' keyword to refer to the person object.
4040
}
4141
};
4242
equals(person.toString(), "I Amory Blaine am 102 years old.", 'what should the toString function be?');

topics/about_operators.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ test("addition", function() {
77
for (var i = 0; i <= 5; i++) {
88
result = result + i;
99
}
10-
equals(result, __, "What is the value of result?");
10+
equals(result, 15, "What is the value of result?");
1111
});
1212

1313
test("assignment addition", function() {
@@ -16,23 +16,23 @@ test("assignment addition", function() {
1616
//the code below is just like saying result = result + i; but is more concise
1717
result += i;
1818
}
19-
equals(result, __, "What is the value of result?");
19+
equals(result, 15, "What is the value of result?");
2020
});
2121

2222
test("subtraction", function() {
2323
var result = 5;
2424
for (var i = 0; i <= 2; i++) {
2525
result = result - i;
2626
}
27-
equals(result, __, "What is the value of result?");
27+
equals(result, 2, "What is the value of result?");
2828
});
2929

3030
test("assignment subtraction", function() {
3131
var result = 5;
3232
for (var i = 0; i <= 2; i++) {
3333
result -= i;
3434
}
35-
equals(result, __, "What is the value of result?");
35+
equals(result, 2, "What is the value of result?");
3636
});
3737

3838
//Assignment operators are available for multiplication and division as well
@@ -43,5 +43,5 @@ test("modulus", function() {
4343
var x = 5;
4444
//again this is exactly the same as result = result % x
4545
result %= x;
46-
equals(result, __, "What is the value of result?");
46+
equals(result, 0, "What is the value of result?");
4747
});

topics/about_prototypal_inheritance.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Mammal.prototype = {
1616

1717
test("defining a 'class'", function() {
1818
var eric = new Mammal("Eric");
19-
equals(eric.sayHi(), __, 'what will Eric say?');
19+
equals(eric.sayHi(), "Hello, my name is Eric", 'what will Eric say?');
2020
});
2121

2222
// add another function to the Mammal 'type' that uses the sayHi function
@@ -26,7 +26,7 @@ Mammal.prototype.favouriteSaying = function() {
2626

2727
test("more functions", function() {
2828
var bobby = new Mammal("Bobby");
29-
equals(bobby.favouriteSaying(), __, "what is Bobby's favourite saying?");
29+
equals(bobby.favouriteSaying(), "Bobby's favourite saying is Hello, my name is Bobby", "what is Bobby's favourite saying?");
3030
});
3131

3232
test("calling functions added to a prototype after an object was created", function() {
@@ -35,7 +35,7 @@ test("calling functions added to a prototype after an object was created", funct
3535
return this.name.length;
3636
};
3737
// for the following statement asks the paul object to call a function that was added to the Mammal prototype after paul was constructed.
38-
equals(paul.numberOfLettersInName(), __, "how long is Paul's name?");
38+
equals(paul.numberOfLettersInName(), 4, "how long is Paul's name?");
3939
});
4040

4141
// helper function for inheritance.
@@ -55,6 +55,6 @@ extend(Bat, Mammal);
5555

5656
test("Inheritance", function() {
5757
var lenny = new Bat("Lenny", "1.5m");
58-
equals(lenny.sayHi(), __, "what does Lenny say?");
59-
equals(lenny.wingspan, __, "what is Lenny's wingspan?");
58+
equals(lenny.sayHi(), "Hello, my name is Lenny", "what does Lenny say?");
59+
equals(lenny.wingspan, "1.5m", "what is Lenny's wingspan?");
6060
});

0 commit comments

Comments
 (0)