Skip to content

Commit 98b39cd

Browse files
committed
about_assignment, control, equality, truthyness changes
1 parent cab5da7 commit 98b39cd

File tree

5 files changed

+44
-29
lines changed

5 files changed

+44
-29
lines changed

topics/about_arrays.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@ 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('Monday','Wednesday');
23+
ok(workingWeek.equalTo(['Tuesday']), 'what is the value of workingWeek?');
24+
ok(daysOfWeek.equalTo(['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']), 'what is the value of daysOfWeek?');
2525
});
2626

2727
test("stack methods", function() {

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: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ 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++) {
14-
counter = counter + i;
14+
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() {
@@ -25,17 +25,18 @@ test("for in", function() {
2525
var result = "";
2626
// for in enumerates the property names of an object
2727
for (property_name in person) {
28+
// console.log(person[property_name]);
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_truthyness.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,36 @@
1-
1+
// http://www.sitepoint.com/javascript-truthy-falsy/
22
module("About Truthyness (topics/about_truthyness.js)");
33

44
test("truthyness of positive numbers", function() {
55
var oneIsTruthy = 1 ? true : false;
6-
equals(oneIsTruthy, __, 'is one truthy?');
6+
equals(oneIsTruthy, true, 'is one truthy?');
77
});
88

99
test("truthyness of negative numbers", function() {
1010
var negativeOneIsTruthy = -1 ? true : false;
11-
equals(negativeOneIsTruthy, __, 'is -1 truthy?');
11+
equals(negativeOneIsTruthy, true, 'is -1 truthy?');
1212
});
1313

1414
test("truthyness of zero", function() {
1515
var zeroIsTruthy = 0 ? true : false;
16-
equals(zeroIsTruthy, __, 'is 0 truthy?');
16+
equals(zeroIsTruthy, false, 'is 0 truthy?');
1717
});
1818

1919
test("truthyness of null", function() {
2020
var nullIsTruthy = null ? true : false;
21-
equals(nullIsTruthy, __, 'is null truthy?');
21+
equals(nullIsTruthy, false, 'is null truthy?');
22+
});
23+
24+
test("truthyness of null against undefined", function () {
25+
ok(null == undefined, 'is null truthy against undefined?');
26+
});
27+
28+
test("truthyness of undefined against undefined", function () {
29+
ok(undefined == undefined, 'is undefined truthy against undefined?');
2230
});
31+
32+
test("truthyness of NaN against undefined", function () {
33+
ok(NaN != undefined, 'is NaN ever truthy');
34+
});
35+
36+

0 commit comments

Comments
 (0)