Skip to content

Commit 986b818

Browse files
author
Em01
committed
Objects and Numbers.
1 parent 8ecfb46 commit 986b818

3 files changed

Lines changed: 78 additions & 78 deletions

File tree

topics/about_control_structures.js

Lines changed: 65 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,73 @@
1-
module("About Control Structures (topics/about_control_structures.js)");
1+
// module("About Control Structures (topics/about_control_structures.js)");
22

3-
test("if", function() {
4-
var isPositive = false;
5-
if (2 > 0) {
6-
isPositive = true;
7-
}
8-
equal(true, isPositive, 'what is the value of isPositive?');
9-
});
3+
// test("if", function() {
4+
// var isPositive = false;
5+
// if (2 > 0) {
6+
// isPositive = true;
7+
// }
8+
// equal(true, isPositive, 'what is the value of isPositive?');
9+
// });
1010

11-
test("for", function() {
12-
var counter = 10;
13-
for (var i = 1; i <= 3; i++) {
14-
counter = counter + i;
15-
}
16-
equal(__, counter, 'what is the value of counter?');
17-
});
11+
// test("for", function() {
12+
// var counter = 10;
13+
// for (var i = 1; i <= 3; i++) {
14+
// counter = counter + i;
15+
// }
16+
// equal(__, counter, 'what is the value of counter?');
17+
// });
1818

19-
test("for in", function() {
20-
// this syntax will be explained in about objects
21-
var person = {
22-
name: "Amory Blaine",
23-
age: 102
24-
};
25-
var result = "";
26-
// for in enumerates the property names of an object
27-
for (var property_name in person) {
28-
result = result + property_name;
29-
}
30-
equal(__, result, 'what is the value of result?');
31-
});
19+
// test("for in", function() {
20+
// // this syntax will be explained in about objects
21+
// var person = {
22+
// name: "Amory Blaine",
23+
// age: 102
24+
// };
25+
// var result = "";
26+
// // for in enumerates the property names of an object
27+
// for (var property_name in person) {
28+
// result = result + property_name;
29+
// }
30+
// equal(__, result, 'what is the value of result?');
31+
// });
3232

33-
test("ternary operator", function() {
34-
var fruit = true ? "apple" : "orange";
35-
equal(__, fruit, 'what is the value of fruit?');
33+
// test("ternary operator", function() {
34+
// var fruit = true ? "apple" : "orange";
35+
// equal(__, fruit, 'what is the value of fruit?');
3636

37-
fruit = false ? "apple" : "orange";
38-
equal(__, fruit, 'now what is the value of fruit?');
39-
});
37+
// fruit = false ? "apple" : "orange";
38+
// equal(__, fruit, 'now what is the value of fruit?');
39+
// });
4040

41-
test("switch", function() {
42-
var result = 0;
43-
switch (2) {
44-
case 1:
45-
result = 1;
46-
break;
47-
case 1+1:
48-
result = 2;
49-
break;
50-
}
51-
equal(__, result, 'what is the value of result?');
52-
});
41+
// test("switch", function() {
42+
// var result = 0;
43+
// switch (2) {
44+
// case 1:
45+
// result = 1;
46+
// break;
47+
// case 1+1:
48+
// result = 2;
49+
// break;
50+
// }
51+
// equal(__, result, 'what is the value of result?');
52+
// });
5353

54-
test("switch default case", function() {
55-
var result = "Pippin";
56-
switch ("m") {
57-
case "f":
58-
result = "Frodo";
59-
break;
60-
case "s":
61-
result = "Samwise";
62-
break;
63-
default:
64-
result = "Merry";
65-
break;
66-
}
67-
equal(__, result, 'what is the value of result?');
68-
});
54+
// test("switch default case", function() {
55+
// var result = "Pippin";
56+
// switch ("m") {
57+
// case "f":
58+
// result = "Frodo";
59+
// break;
60+
// case "s":
61+
// result = "Samwise";
62+
// break;
63+
// default:
64+
// result = "Merry";
65+
// break;
66+
// }
67+
// equal(__, result, 'what is the value of result?');
68+
// });
6969

70-
test("null coalescing", function() {
71-
var result = null || "a value";
72-
equal(__, result, 'what is the value of result?');
73-
});
70+
// test("null coalescing", function() {
71+
// var result = null || "a value";
72+
// equal(__, result, 'what is the value of result?');
73+
// });

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-
equal(__, typeOfIntegers === typeOfFloats, 'are ints and floats the same type?');
8-
equal(__, typeOfIntegers, 'what is the javascript numeric type?');
9-
equal(__, 1.0, 'what is a integer number equivalent to 1.0?');
7+
equal(true, typeOfIntegers === typeOfFloats, 'are ints and floats the same type?');
8+
equal("number", typeOfIntegers, 'what is the javascript numeric type?');
9+
equal(1, 1.0, 'what is a integer number equivalent to 1.0?');
1010
});
1111

1212
test("NaN", function() {
1313
var resultOfFailedOperations = 7/'apple';
14-
equal(__, isNaN(resultOfFailedOperations), 'what will satisfy the equals assertion?');
15-
equal(__, resultOfFailedOperations == NaN, 'is NaN == NaN?');
14+
equal(true, isNaN(resultOfFailedOperations), 'what will satisfy the equals assertion?');
15+
equal(false, resultOfFailedOperations == NaN, '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-
equal(__, typeof(empty_object), 'what is the type of an object?');
6+
equal("object", typeof(empty_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
equal("Amory Blaine", person.name, "what is the person's name?");
1515
equal(102, person.age, "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
equal("Amory Blaine", person.name, "what is the person's name?");
2323
equal(102, person.age, "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
equal("Amory Blaine", person.name, "what is the person's name?");
3131
equal(102, person.age, "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 "I" + " " + this.name + " am" + " " + this.age + " years old."; // HINT: use the 'this' keyword to refer to the person object.
4040
}
4141
};
4242
equal("I Amory Blaine am 102 years old.", person.toString(), "what should the toString function be?");

0 commit comments

Comments
 (0)