Skip to content

Commit 7308bea

Browse files
committed
normalizing tabs and removing jquery wrappers
1 parent 09ea0b1 commit 7308bea

File tree

7 files changed

+265
-295
lines changed

7 files changed

+265
-295
lines changed

topics/about_arrays.js

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,34 @@
11

2-
$(document).ready(function(){
2+
module("About Arrays (topics/about_arrays.js)");
33

4-
module("About Arrays (topics/about_arrays.js)");
5-
6-
test("array literal syntax and indexing", function() {
7-
var favouriteThings = ["cellar door", 42, true]; // note that array elements do not have to be of the same type
8-
equals(favouriteThings[0], __, 'what is in the first position of the array?');
9-
equals(favouriteThings[1], __, 'what is in the second position of the array?');
10-
equals(favouriteThings[2], __, 'what is in the third position of the array?');
11-
});
12-
13-
test("array type", function() {
14-
equals(typeof([]), __, 'what is the type of an array?');
15-
});
4+
test("array literal syntax and indexing", function() {
5+
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?');
9+
});
1610

17-
test("length", function() {
18-
var collection = ['a','b','c'];
19-
equals(collection.length, __, 'what is the length of the collection array?');
20-
});
11+
test("array type", function() {
12+
equals(typeof([]), __, 'what is the type of an array?');
13+
});
2114

22-
test("delete", function() {
23-
var daysOfWeek = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
24-
var workingWeek = daysOfWeek.splice(__, __);
25-
ok(workingWeek.equalTo([__]), 'what is the value of workingWeek?');
26-
ok(daysOfWeek.equalTo([__]), 'what is the value of daysOfWeek?');
27-
});
15+
test("length", function() {
16+
var collection = ['a','b','c'];
17+
equals(collection.length, __, 'what is the length of the collection array?');
18+
});
2819

29-
test("stack methods", function() {
30-
var stack = [];
31-
stack.push("first");
32-
stack.push("second");
20+
test("delete", function() {
21+
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?');
25+
});
3326

34-
equals(stack.pop(), __, 'what will be the first value poped off the stack?');
35-
equals(stack.pop(), __, 'what will be the second value poped off the stack?');
36-
});
27+
test("stack methods", function() {
28+
var stack = [];
29+
stack.push("first");
30+
stack.push("second");
3731

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?');
3834
});
39-

topics/about_control_structures.js

Lines changed: 64 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,74 @@
11

2-
$(document).ready(function(){
2+
module("About Control Structures (topics/about_control_structures.js)");
33

4-
module("About Control Structures (topics/about_control_structures.js)");
5-
6-
test("if", function() {
7-
var isPositive = false;
8-
if (2 > 0) {
9-
isPositive = true;
10-
}
11-
equals(isPositive, __, 'what is the value of isPositive?');
12-
});
13-
14-
test("for", function() {
15-
var counter = 10;
16-
for (var i = 1; i <= 3; i++) {
17-
counter = counter + i;
18-
}
19-
equals(counter, __, 'what is the value of counter?');
20-
});
4+
test("if", function() {
5+
var isPositive = false;
6+
if (2 > 0) {
7+
isPositive = true;
8+
}
9+
equals(isPositive, __, 'what is the value of isPositive?');
10+
});
2111

22-
test("for in", function() {
23-
// this syntax will be explained in about objects
24-
var person = {
25-
name: "Amory Blaine",
26-
age: 102
27-
};
28-
var result = "";
29-
// for in enumerates the property names of an object
30-
for (property_name in person) {
31-
result = result + property_name;
32-
};
33-
equals(result, __, 'what is the value of result?');
34-
});
12+
test("for", function() {
13+
var counter = 10;
14+
for (var i = 1; i <= 3; i++) {
15+
counter = counter + i;
16+
}
17+
equals(counter, __, 'what is the value of counter?');
18+
});
3519

36-
test("ternary operator", function() {
37-
var fruit = true ? "apple" : "orange";
38-
equals(fruit, __, 'what is the value of fruit?');
20+
test("for in", function() {
21+
// this syntax will be explained in about objects
22+
var person = {
23+
name: "Amory Blaine",
24+
age: 102
25+
};
26+
var result = "";
27+
// for in enumerates the property names of an object
28+
for (property_name in person) {
29+
result = result + property_name;
30+
};
31+
equals(result, __, 'what is the value of result?');
32+
});
3933

40-
fruit = false ? "apple" : "orange";
41-
equals(fruit, __, 'now what is the value of fruit?');
42-
});
34+
test("ternary operator", function() {
35+
var fruit = true ? "apple" : "orange";
36+
equals(fruit, __, 'what is the value of fruit?');
4337

44-
test("switch", function() {
45-
var result = 0;
46-
switch (2) {
47-
case 1:
48-
result = 1;
49-
break;
50-
case 1+1:
51-
result = 2;
52-
break;
53-
}
54-
equals(result, __, 'what is the value of result?');
55-
});
38+
fruit = false ? "apple" : "orange";
39+
equals(fruit, __, 'now what is the value of fruit?');
40+
});
5641

57-
test("switch default case", function() {
58-
var result = "Pippin";
59-
switch ("m") {
60-
case "f":
61-
result = "Frodo";
62-
break;
63-
case "s":
64-
result = "Samwise";
65-
break;
66-
default:
67-
result = "Merry";
68-
break;
69-
}
70-
equals(result, __, 'what is the value of result?');
71-
});
42+
test("switch", function() {
43+
var result = 0;
44+
switch (2) {
45+
case 1:
46+
result = 1;
47+
break;
48+
case 1+1:
49+
result = 2;
50+
break;
51+
}
52+
equals(result, __, 'what is the value of result?');
53+
});
7254

73-
test("null coallescion", function() {
74-
var result = null || "a value";
75-
equals(result, __, 'what is the value of result?');
76-
});
55+
test("switch default case", function() {
56+
var result = "Pippin";
57+
switch ("m") {
58+
case "f":
59+
result = "Frodo";
60+
break;
61+
case "s":
62+
result = "Samwise";
63+
break;
64+
default:
65+
result = "Merry";
66+
break;
67+
}
68+
equals(result, __, 'what is the value of result?');
69+
});
7770

71+
test("null coallescion", function() {
72+
var result = null || "a value";
73+
equals(result, __, 'what is the value of result?');
7874
});

topics/about_numbers.js

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11

2-
$(document).ready(function(){
2+
module("About Numbers (topics/about_numbers.js)");
33

4-
module("About Numbers (topics/about_numbers.js)");
5-
6-
test("types", function() {
7-
var typeOfIntegers = typeof(6);
8-
var typeOfFloats = typeof(3.14159);
9-
equals(typeOfIntegers === typeOfFloats, __, 'are ints and floats the same type?');
10-
equals(typeOfIntegers, __, 'what is the javascript numeric type?');
11-
equals(1.0, __, 'what is a integer number equivalent to 1.0?');
12-
});
13-
14-
test("NaN", function() {
15-
var resultOfFailedOperations = 7/'apple';
16-
equals(isNaN(resultOfFailedOperations), __, 'what will satisfy the equals assertion?');
17-
equals(resultOfFailedOperations == NaN, __, 'is NaN == NaN?');
18-
});
4+
test("types", function() {
5+
var typeOfIntegers = typeof(6);
6+
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?');
10+
});
1911

12+
test("NaN", function() {
13+
var resultOfFailedOperations = 7/'apple';
14+
equals(isNaN(resultOfFailedOperations), __, 'what will satisfy the equals assertion?');
15+
equals(resultOfFailedOperations == NaN, __, 'is NaN == NaN?');
2016
});

topics/about_objects.js

Lines changed: 38 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,43 @@
11

2-
$(document).ready(function(){
2+
module("About Objects (topics/about_objects.js)");
33

4-
module("About Objects (topics/about_objects.js)");
4+
test("object type", function() {
5+
var empty_object = {};
6+
equals(typeof(empty_object), __, 'what is the type of an object?');
7+
});
8+
9+
test("object literal notation", function() {
10+
var person = {
11+
__:__,
12+
__:__
13+
};
14+
equals(person.name, "Amory Blaine", 'what is the person\'s name?');
15+
equals(person.age, 102, 'what is the person\'s age?');
16+
});
517

6-
test("object type", function() {
7-
var empty_object = {};
8-
equals(typeof(empty_object), __, 'what is the type of an object?');
9-
});
18+
test("dynamically adding properties", function() {
19+
var person = {};
20+
person.__ = "Amory Blaine";
21+
person.__ = 102;
22+
equals(person.name, "Amory Blaine", 'what is the person\'s name?');
23+
equals(person.age, 102, 'what is the person\'s age?');
24+
});
25+
26+
test("adding properties from strings", function() {
27+
var person = {};
28+
person["__"] = "Amory Blaine";
29+
person["__"] = 102;
30+
equals(person.name, "Amory Blaine", 'what is the person\'s name?');
31+
equals(person.age, 102, 'what is the person\'s age?');
32+
});
1033

11-
test("object literal notation", function() {
12-
var person = {
13-
__:__,
14-
__:__
15-
};
16-
equals(person.name, "Amory Blaine", 'what is the person\'s name?');
17-
equals(person.age, 102, 'what is the person\'s age?');
18-
});
19-
20-
test("dynamically adding properties", function() {
21-
var person = {};
22-
person.__ = "Amory Blaine";
23-
person.__ = 102;
24-
equals(person.name, "Amory Blaine", 'what is the person\'s name?');
25-
equals(person.age, 102, 'what is the person\'s age?');
26-
});
27-
28-
test("adding properties from strings", function() {
29-
var person = {};
30-
person["__"] = "Amory Blaine";
31-
person["__"] = 102;
32-
equals(person.name, "Amory Blaine", 'what is the person\'s name?');
33-
equals(person.age, 102, 'what is the person\'s age?');
34-
});
35-
36-
test("adding functions", function() {
37-
var person = {
38-
name: "Amory Blaine",
39-
age: 102,
40-
toString: function() {
41-
return __; // HINT: use the 'this' keyword to refer to the person object.
42-
}
43-
};
44-
equals(person.toString(), "I Amory Blaine am 102 years old.", 'what should the toString function be?');
45-
});
46-
34+
test("adding functions", function() {
35+
var person = {
36+
name: "Amory Blaine",
37+
age: 102,
38+
toString: function() {
39+
return __; // HINT: use the 'this' keyword to refer to the person object.
40+
}
41+
};
42+
equals(person.toString(), "I Amory Blaine am 102 years old.", 'what should the toString function be?');
4743
});

0 commit comments

Comments
 (0)