Skip to content

Commit b9d4791

Browse files
Alex WeiksnarAlex Weiksnar
authored andcommitted
40 koans
1 parent 4ab7622 commit b9d4791

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

topics/about_arrays.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ 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() {

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?");

topics/about_strings.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ test("escape character", function() {
2525

2626
test("string.length", function() {
2727
var fruit = "apple";
28-
equal(__, fruit.length, 'what is the value of fruit.length?');
28+
equal(5, fruit.length, 'what is the value of fruit.length?');
2929
});
3030

3131
test("slice", function() {
3232
var fruit = "apple pie";
33-
equal(__, fruit.slice(0,5), 'what is the value of fruit.slice(0,5)?');
33+
equal("apple", fruit.slice(0,5), 'what is the value of fruit.slice(0,5)?');
3434
});

0 commit comments

Comments
 (0)