Skip to content

Commit bf09d30

Browse files
author
Stephania
committed
Done with operators
1 parent 9167fc5 commit bf09d30

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

topics/about_arrays.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,34 @@ module("About Arrays (topics/about_arrays.js)");
22

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

1010
test("array type", function() {
11-
equal(__, typeof([]), 'what is the type of an array?');
11+
equal(string, typeof([]), 'what is the type of an array?');
1212
});
1313

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

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

2626
test("stack methods", function() {
2727
var stack = [];
2828
stack.push("first");
2929
stack.push("second");
3030

31-
equal(__, stack.pop(), 'what will be the first value popped off the stack?');
32-
equal(__, stack.pop(), 'what will be the second value popped off the stack?');
31+
equal("second", stack.pop(), 'what will be the first value popped off the stack?');
32+
equal("first", stack.pop(), 'what will be the second value popped off the stack?');
3333
});
3434

3535
test("queue methods", function() {
@@ -38,6 +38,6 @@ test("queue methods", function() {
3838
queue.push("second");
3939
queue.unshift("third");
4040

41-
equal(__, queue.shift(), 'what will be shifted out first?');
42-
equal(__, queue.shift(), 'what will be shifted out second?');
41+
equal("third", queue.shift(), 'what will be shifted out first?');
42+
equal("first", queue.shift(), 'what will be shifted out second?');
4343
});

topics/about_equality.js

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

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

88
test("string equality", function() {
9-
equal("3" + __, "37", "concatenate the strings");
9+
equal("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() {

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-
equal(__, result, "What is the value of result?");
10+
equal(15, result, "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-
equal(__, result, "What is the value of result?");
19+
equal(15, result, "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-
equal(__, result, "What is the value of result?");
27+
equal(2, result, "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-
equal(__, result, "What is the value of result?");
35+
equal(2, result, "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-
equal(__, result, "What is the value of result?");
46+
equal(0, result, "What is the value of result?");
4747
});

0 commit comments

Comments
 (0)