Within my code, I have run into a bug.
If you run this javascript code and look at what the console outputs.
I will have a todo list I will enter new put in something I want to do great its added to the array. I will then hit new again, great, added another thing to do to the array.
Right now I should have two items in my array [0] and [1] correct?
If I try to delete the items it does not work. I have to use the delete key terms like two times then hit the list for it to work again? Idk if its just a bug on my side but run my javascript application use the keyterms in the HTML page and try and add new things to do, list them, then try deleting them. It works but it doesn't work on the first try.
Warning will cause the browser to continuously open alerts until quit is typed
var todos = [""];
var input = prompt("What would you like to do today?");
while (input !== "quit") {
if (input === "list") {
todos.forEach(function(todo, i) {
console.log(i + ": " + todo);
});
} else if (input === "new") {
var newTodo = prompt("Enter new thing to do");
todos.push(newTodo);
} else if (input === "delete") {
var index = prompt("Enter index of todo to delete");
todos.splice(index, 1);
}
input = prompt("What would you like to do?");
}
console.log("Ok, you have quit the application");
<!DOCTYPE html>
<html>
<head>
<title>Todo List</title>
</head>
<body>
<h1>To Do List</h1>
<ul>
<li>"new" - Add A Todo</li>
<li>"list" - List all Todos</li>
<li>"Delete" A Specific Todo</li>
<li>"quit" - quit the application</li>
</ul>
</body>
</html>