Skip to content
Browse files

arrays removeWithoutCopy

  • Loading branch information...
1 parent c37b1f2 commit c0b39dcbfaac6b61f6deb51b1406f05e5714117e @ainthek ainthek committed Sep 2, 2012
Showing with 13 additions and 0 deletions.
  1. +4 −0 app/arrays.js
  2. +9 −0 tests/app/arrays.js
View
4 app/arrays.js
@@ -13,6 +13,10 @@ define(function() {
remove : function(arr, item) {
},
+
+ removeWithoutCopy : function(arr, item) {
+
+ },
append : function(arr, item) {
View
9 tests/app/arrays.js
@@ -27,6 +27,15 @@ define([
expect(result).to.have.length(3);
expect(result.join(' ')).to.be('1 3 4');
});
+
+ it("you should be able to remove a value from an array (without making copy of original array)", function() {
+ a.push(2); // Make sure the value appears more than one time
+ var result = answers.removeWithoutCopy(a, 2);
+
+ expect(result).to.have.length(3);
+ expect(result.join(' ')).to.be('1 3 4');
+ expect(result).equal(a); //make sure that you return the same instance of array
+ });
it("you should be able to add an item to the end of an array", function() {
var result = answers.append(a, 10);

0 comments on commit c0b39dc

Please sign in to comment.
Something went wrong with that request. Please try again.