Skip to content
Open
Show file tree
Hide file tree
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
5 changes: 0 additions & 5 deletions dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,6 @@
update(newState);
});
todoNode.appendChild(deleteButtonNode);

// add markTodo button

// add classes for css

return todoNode;
};

Expand Down
6 changes: 3 additions & 3 deletions logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "",
"main": "dom.js",
"scripts": {
"test": "node test.js | tap-spec"
"test": "tape test.js | tap-spec"
},
"repository": {
"type": "git",
Expand Down
11 changes: 5 additions & 6 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ test("Adding items", function(t) {
});

test("Deleting items", function(t) {
var actual = [
var todos = [
{
id: 1,
status: false,
Expand All @@ -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,
Expand All @@ -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();
});
Expand Down