Skip to content

Commit ce73978

Browse files
committed
finished assignments
1 parent be8ff71 commit ce73978

File tree

9 files changed

+46
-46
lines changed

9 files changed

+46
-46
lines changed

topics/about_asserts.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ $(document).ready(function(){
44
module("About Asserts (topics/about_asserts.js)");
55

66
test("ok", function() {
7-
ok(false, 'what will satisfy the ok assertion?');
7+
ok(true, 'what will satisfy the ok assertion?');
88
});
99

1010
test("not", function() {
11-
not(__, 'what is a false value?');
11+
not(0, 'what is a false value?');
1212
});
1313

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

1818
});

topics/about_assignment.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ $(document).ready(function(){
44
module("About Assignment (topics/about_assignment.js)");
55

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

1111
test("global variables", function() {
1212
temp = 1;
13-
equals(temp, window.__, 'global variables are assigned to the window object');
13+
equals(temp, window.temp, 'global variables are assigned to the window object');
1414
});
1515

1616
});

topics/about_control_structures.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ $(document).ready(function(){
88
if (2 > 0) {
99
isPositive = true;
1010
}
11-
equals(isPositive, __, 'what is the value of isPositive?');
11+
equals(isPositive, true, 'what is the value of isPositive?');
1212
});
1313

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

2222
test("for in", function() {
@@ -30,15 +30,15 @@ $(document).ready(function(){
3030
for (property_name in person) {
3131
result = result + property_name;
3232
};
33-
equals(result, __, 'what is the value of result?');
33+
equals(result, "nameage", 'what is the value of result?');
3434
});
3535

3636
test("ternary operator", function() {
3737
var fruit = true ? "apple" : "orange";
38-
equals(fruit, __, 'what is the value of fruit?');
38+
equals(fruit, "apple", 'what is the value of fruit?');
3939

4040
fruit = false ? "apple" : "orange";
41-
equals(fruit, __, 'now what is the value of fruit?');
41+
equals(fruit, "orange", 'now what is the value of fruit?');
4242
});
4343

4444
test("switch", function() {
@@ -51,7 +51,7 @@ $(document).ready(function(){
5151
result = 2;
5252
break;
5353
}
54-
equals(result, __, 'what is the value of result?');
54+
equals(result,2, 'what is the value of result?');
5555
});
5656

5757
test("switch default case", function() {
@@ -67,12 +67,12 @@ $(document).ready(function(){
6767
result = "Merry";
6868
break;
6969
}
70-
equals(result, __, 'what is the value of result?');
70+
equals(result, "Merry", 'what is the value of result?');
7171
});
7272

7373
test("null coallescion", function() {
7474
var result = null || "a value";
75-
equals(result, __, 'what is the value of result?');
75+
equals(result, "a value", 'what is the value of result?');
7676
});
7777

7878
});

topics/about_equality.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@ $(document).ready(function(){
44
module("About Equality (topics/about_equality.js)");
55

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

1010
test("string equality", function() {
11-
equals("3" + __, "37", "concatenate the strings");
11+
equals("3" + "7", "37", "concatenate the strings");
1212
});
1313

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

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

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

2626
});

topics/about_numbers.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ $(document).ready(function(){
66
test("types", function() {
77
var typeOfIntegers = typeof(6);
88
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?');
9+
equals(typeOfIntegers === typeOfFloats, true, 'are ints and floats the same type?');
10+
equals(typeOfIntegers, "number", 'what is the javascript numeric type?');
11+
equals(1.0, 1, 'what is a integer number equivalent to 1.0?');
1212
});
1313

1414
test("NaN", function() {
1515
var resultOfFailedOperations = 7/'apple';
16-
equals(isNaN(resultOfFailedOperations), __, 'what will satisfy the equals assertion?');
17-
equals(resultOfFailedOperations == NaN, __, 'is NaN == NaN?');
16+
equals(isNaN(resultOfFailedOperations), true, 'what will satisfy the equals assertion?');
17+
equals(resultOfFailedOperations == NaN, false, 'is NaN == NaN?');
1818
});
1919

2020
});

topics/about_objects.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,30 @@ $(document).ready(function(){
55

66
test("object type", function() {
77
var empty_object = {};
8-
equals(typeof(empty_object), __, 'what is the type of an object?');
8+
equals(typeof(empty_object), "object", 'what is the type of an object?');
99
});
1010

1111
test("object literal notation", function() {
1212
var person = {
13-
__:__,
14-
__:__
13+
name:"Amory Blaine",
14+
age:102
1515
};
1616
equals(person.name, "Amory Blaine", 'what is the person\'s name?');
1717
equals(person.age, 102, 'what is the person\'s age?');
1818
});
1919

2020
test("dynamically adding properties", function() {
2121
var person = {};
22-
person.__ = "Amory Blaine";
23-
person.__ = 102;
22+
person.name = "Amory Blaine";
23+
person.age = 102;
2424
equals(person.name, "Amory Blaine", 'what is the person\'s name?');
2525
equals(person.age, 102, 'what is the person\'s age?');
2626
});
2727

2828
test("adding properties from strings", function() {
2929
var person = {};
30-
person["__"] = "Amory Blaine";
31-
person["__"] = 102;
30+
person["name"] = "Amory Blaine";
31+
person["age"] = 102;
3232
equals(person.name, "Amory Blaine", 'what is the person\'s name?');
3333
equals(person.age, 102, 'what is the person\'s age?');
3434
});
@@ -38,7 +38,7 @@ $(document).ready(function(){
3838
name: "Amory Blaine",
3939
age: 102,
4040
toString: function() {
41-
return __; // HINT: use the 'this' keyword to refer to the person object.
41+
return "I " + this.name + " am " + this.age + " years old."; // HINT: use the 'this' keyword to refer to the person object.
4242
}
4343
};
4444
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
@@ -8,7 +8,7 @@ $(document).ready(function(){
88
for (var i = 0; i <= 5; i++) {
99
result = result + i;
1010
}
11-
equals(result, __, "What is the value of result?");
11+
equals(result, 15, "What is the value of result?");
1212
});
1313

1414
test("assignment addition", function() {
@@ -17,23 +17,23 @@ $(document).ready(function(){
1717
//the code below is just like saying result = result + i; but is more concise
1818
result += i;
1919
}
20-
equals(result, __, "What is the value of result?");
20+
equals(result, 15, "What is the value of result?");
2121
});
2222

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

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

3939
//Assignment operators are available for multiplication and division as well
@@ -44,7 +44,7 @@ $(document).ready(function(){
4444
var x = 5;
4545
//again this is exactly the same as result = result % x
4646
result %= x;
47-
equals(result, __, "What is the value of result?");
47+
equals(result, 0, "What is the value of result?");
4848
});
4949

5050
});

topics/about_strings.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,33 @@ $(document).ready(function(){
66
test("delimiters", function() {
77
var singleQuotedString = 'apple';
88
var doubleQuotedString = "apple";
9-
equals(singleQuotedString === doubleQuotedString, __, 'are the two strings equal?');
9+
equals(singleQuotedString === doubleQuotedString, true, 'are the two strings equal?');
1010
});
1111

1212
test("concatenation", function() {
1313
var fruit = "apple";
1414
var dish = "pie";
15-
equals(fruit + " " + dish, __, 'what is the value of fruit + " " + dish?');
15+
equals(fruit + " " + dish, "apple pie", 'what is the value of fruit + " " + dish?');
1616
});
1717

1818
test("character Type", function() {
1919
var characterType = typeof("Amory".charAt(1)); // typeof will be explained in about reflection
20-
equals(characterType, __, 'Javascript has no character type');
20+
equals(characterType, "string", 'Javascript has no character type');
2121
});
2222

2323
test("escape character", function() {
2424
var stringWithAnEscapedCharacter = "\u0041pple";
25-
equals(stringWithAnEscapedCharacter, __, 'what is the value of stringWithAnEscapedCharacter?');
25+
equals(stringWithAnEscapedCharacter, "Apple", 'what is the value of stringWithAnEscapedCharacter?');
2626
});
2727

2828
test("string.length", function() {
2929
var fruit = "apple";
30-
equals(fruit.length, __, 'what is the value of fruit.length?');
30+
equals(fruit.length, 5, 'what is the value of fruit.length?');
3131
});
3232

3333
test("slice", function() {
3434
var fruit = "apple pie";
35-
equals(fruit.slice(0,5), __, 'what is the value of fruit.slice(0,5)?');
35+
equals(fruit.slice(0,5), "apple", 'what is the value of fruit.slice(0,5)?');
3636
});
3737

3838
});

topics/about_truthyness.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,22 @@ $(document).ready(function(){
55

66
test("truthyness of positive numbers", function() {
77
var oneIsTrue = 1 ? true : false;
8-
equals(oneIsTrue, __, 'is one true?');
8+
equals(oneIsTrue, 1, 'is one true?');
99
});
1010

1111
test("truthyness of negative numbers", function() {
1212
var negativeOneIsTrue = -1 ? true : false;
13-
equals(negativeOneIsTrue, __, 'is -1 true?');
13+
equals(negativeOneIsTrue, true, 'is -1 true?');
1414
});
1515

1616
test("truthyness of zero", function() {
1717
var zeroIsTrue = 0 ? true : false;
18-
equals(zeroIsTrue, __, 'is 0 true?');
18+
equals(zeroIsTrue, false, 'is 0 true?');
1919
});
2020

2121
test("truthyness of null", function() {
2222
var nullIsTrue = null ? true : false;
23-
equals(nullIsTrue, __);
23+
equals(nullIsTrue, false);
2424
});
2525

2626
});

0 commit comments

Comments
 (0)