Skip to content

Instantly share code, notes, and snippets.

@barnes7td
Last active November 9, 2016 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barnes7td/b65ed78e10554d21dcdd777295437c3c to your computer and use it in GitHub Desktop.
Save barnes7td/b65ed78e10554d21dcdd777295437c3c to your computer and use it in GitHub Desktop.
// INSTRUCTIONS:
// Create a function named createArray. This function should:
// 1. take four arguments
// 2. return an array with those arguments as elements
// Tests Given:
var expect = require("chai").expect;
describe("createArray", function() {
it("is defined", function() {
expect(createArray).to.exist;
});
it("creates an array of numbers", function() {
expect(createArray(1,2,3,4)).to.eql([1,2,3,4]);
});
it("creates an array of strings", function() {
expect(createArray("a", "b", "c", "d")).to.eql(["a", "b", "c", "d"]);
});
it("creates an array of non-sequential elements", function() {
expect(createArray(1,4,2,3)).to.eql([1,4,2,3]);
});
});
// Starting Code:
function createArray() {
}
// Current Answer:
function createArray() {
var array = [1, 2, 3, 4];
return array;
}
createArray(1, 2, 3, 4);
// Student: I can pass 1 test, but not both. What am I doing wrong?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment