Created
May 31, 2020 21:41
-
-
Save DoviMaj/8968e4dc7ea449f2f81588ba4ea70f57 to your computer and use it in GitHub Desktop.
todoList
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Practical JS</title> | |
</head> | |
<body> | |
<script> | |
let todosList = { | |
todos: [], | |
displayTodos: function(){ | |
if(this.todos.lenght === 0){ | |
console.log("your list is empty"); | |
} else { | |
console.log("My Todos:"); | |
for(var i = 0; i < this.todos.length; i++){ | |
console.log(this.todos[i].todoText); | |
} | |
} | |
}, | |
addTodo: function(todoText){ | |
this.todos.push({ | |
todoText: todoText, | |
completed: false | |
}); | |
this.displayTodos(); | |
}, | |
changeTodo: function(position, todoText){ | |
this.todos[position].todoText = todoText; | |
this.displayTodos(); | |
}, | |
deleteTodo: function(position){ | |
this.todos.splice(position, 1); | |
this.displayTodos(); | |
}, | |
toggleCompleted: function(position){ | |
this.todos[position].completed = !this.todos[position].completed; | |
this.displayTodos(); | |
} | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I guess you are right. There is no Javascript property for an array called Array.lenght