forked from liammclennan/JavaScript-Koans
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathabout_arrays.js
More file actions
34 lines (27 loc) · 1.3 KB
/
about_arrays.js
File metadata and controls
34 lines (27 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
module("About Arrays (topics/about_arrays.js)");
test("array literal syntax and indexing", function() {
var favouriteThings = ["cellar door", 42, true]; // note that array elements do not have to be of the same type
equals(favouriteThings[0], __, 'what is in the first position of the array?');
equals(favouriteThings[1], __, 'what is in the second position of the array?');
equals(favouriteThings[2], __, 'what is in the third position of the array?');
});
test("array type", function() {
equals(typeof([]), __, 'what is the type of an array?');
});
test("length", function() {
var collection = ['a','b','c'];
equals(collection.length, __, 'what is the length of the collection array?');
});
test("splice", function() {
var daysOfWeek = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
var workingWeek = daysOfWeek.splice(__, __);
ok(workingWeek.equalTo([__]), 'what is the value of workingWeek?');
ok(daysOfWeek.equalTo([__]), 'what is the value of daysOfWeek?');
});
test("stack methods", function() {
var stack = [];
stack.push("first");
stack.push("second");
equals(stack.pop(), __, 'what will be the first value poped off the stack?');
equals(stack.pop(), __, 'what will be the second value poped off the stack?');
});