Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update about_arrays.js #110

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions topics/about_arrays.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ 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
equal(__, favouriteThings[0], 'what is in the first position of the array?');
equal(__, favouriteThings[1], 'what is in the second position of the array?');
equal(__, favouriteThings[2], 'what is in the third position of the array?');
equal(cellar door, favouriteThings[0], 'what is in the first position of the array?');
equal(42, favouriteThings[1], 'what is in the second position of the array?');
equal(true, favouriteThings[2], 'what is in the third position of the array?');
});

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

test("length", function() {
var collection = ['a','b','c'];
equal(__, collection.length, 'what is the length of the collection array?');
equal(3, 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(__, __);
var workingWeek = daysOfWeek.splice(5, 2);
var weekend = daysOfWeek;

deepEqual(workingWeek, ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'], 'what is the value of workingWeek?');
Expand All @@ -30,8 +30,8 @@ test("stack methods", function() {
stack.push("first");
stack.push("second");

equal(__, stack.pop(), 'what will be the first value popped off the stack?');
equal(__, stack.pop(), 'what will be the second value popped off the stack?');
equal("second", stack.pop(), 'what will be the first value popped off the stack?');
equal("first", stack.pop(), 'what will be the second value popped off the stack?');
});

test("queue methods", function() {
Expand All @@ -40,6 +40,6 @@ test("queue methods", function() {
queue.push("second");
queue.unshift("third");

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