-
Notifications
You must be signed in to change notification settings - Fork 0
5 Bugs & Performance
Aashir Sohail edited this page Aug 12, 2020
·
5 revisions
1. index.html - line 16 the missing id tag was preventing the toggle all button to fail.
<input class="toggle-all" type="checkbox">
<input id="toggle-all" class="toggle-all" type="checkbox">
2. controller.js -ine 96 The spelling mistake prevented from the new to-do to being added.
Controller.prototype.adddItem
Controller.prototype.addItem
3. store.js - line 87 The new added was assigned before being checked whether its already presnt or not.
for (var i = 0; i < 6; i++) {
newId += charset.charAt(Math.floor(Math.random() * charset.length));
}
var repeat = true;
while (repeat) {
for (var i = 0; i < 6; i++) {
newId += charset.charAt(Math.floor(Math.random() * charset.length));
}
repeat = false;
todos.forEach( todo => {
if(todo.id === newId) repeat = true;
});
}
store.js - line 127
Issue: Double for loop that iterates the to-dos to get the id, then another loop iterates to split/remove that to-do
for (var i = 0; i < todos.length; i++) {
if (todos[i].id == id) {
todoId = todos[i].id;
}
}
for (var i = 0; i < todos.length; i++) {
if (todos[i].id == todoId) {
todos.splice(i, 1);
}
}
for (var i = 0; i < todos.length; i++) {
if (todos[i].id == id) {
todos.splice(i, 1);
}
}