From 9da4918f715c1794b089ad665b17bba271dad102 Mon Sep 17 00:00:00 2001 From: yusralahleeh Date: Thu, 27 Jun 2019 13:26:44 +0300 Subject: [PATCH 1/2] fixed the pure function thing --- logic.js | 6 +++--- test.js | 11 +++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/logic.js b/logic.js index f8eba09..4fcecb0 100644 --- a/logic.js +++ b/logic.js @@ -13,7 +13,7 @@ var todoFunctions = { } return incrementCounter; - })(), + })(), //this line for when we excute this code the functin call it selfe //cloneArrayOfObjects will create a copy of the todos array //changes to the new array don't affect the original @@ -43,13 +43,13 @@ var todoFunctions = { }); return result; }, - markTodo: function(todos, idToMark) { // should leave the input argument todos unchanged (you can use cloneArrayOfObjects) // in the new todo array, all elements will remain unchanged except the one with id: idToMark // this element will have its done value toggled // hint: array.map - var updated = todos.map(function(ele) { + var updated = this.cloneArrayOfObjects(todos); + updated = updated.map(function(ele) { if (ele.id == idToMark) { ele.status = !ele.status; } diff --git a/test.js b/test.js index 0ce618a..da41a69 100644 --- a/test.js +++ b/test.js @@ -34,7 +34,7 @@ test("Adding items", function(t) { }); test("Deleting items", function(t) { - var actual = [ + var todos = [ { id: 1, status: false, @@ -55,14 +55,14 @@ test("Deleting items", function(t) { } ]; - var idToDelete = actual[0].id; - actual = logic.deleteTodo(actual, 2); + var idToDelete = todos[0].id; + var actual = logic.deleteTodo(todos, 2); t.deepEqual(actual, expected, "Should return array with deleted to do"); t.end(); }); test("Mark ToDo", function(t) { - var actual = [ + var todos = [ { id: 1, status: false, @@ -88,8 +88,7 @@ test("Mark ToDo", function(t) { } ]; var idToMark = 1; - actual = logic.markTodo(actual, idToMark); - + var actual = logic.markTodo(todos, idToMark); t.deepEqual(actual, expected, "Should return a marked toDo"); t.end(); }); From 3db67ed881d359fadd6dec96f89f0226a1f0bd9f Mon Sep 17 00:00:00 2001 From: yusralahleeh Date: Thu, 27 Jun 2019 14:22:02 +0300 Subject: [PATCH 2/2] reolved conflict --- dom.js | 5 ----- package.json | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/dom.js b/dom.js index 9286003..0f3fa63 100644 --- a/dom.js +++ b/dom.js @@ -95,11 +95,6 @@ update(newState); }); todoNode.appendChild(deleteButtonNode); - - // add markTodo button - - // add classes for css - return todoNode; }; diff --git a/package.json b/package.json index 999a400..737dfbc 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "", "main": "dom.js", "scripts": { - "test": "node test.js | tap-spec" + "test": "tape test.js | tap-spec" }, "repository": { "type": "git",