Project: ToDo Manager
JavaScript Objects and Arrays allow us to create much more useful programs by combining related values and being able to work with any number of them. We'll put that into practice by building a text-based to-do list manager.
With simple commands, your program will be able to show a list of things you need to do, add new items, and mark them as completed. Unfortunately, our list will only exist while the program is running and it'll be reset when you quit. We can fix this when we learn more about files or databases.
Setup
- Go to the repl.it page for our class and scroll down until you see the Projects section.
- Click the project title ToDo Manager and this will create a fork, your very own copy of my starter project.
- Click the Run button and see how the code I wrote works. Notice where the
console.log()
statements are that you should replace with your own code.
Instructions
You need to write the following functions to add features to our program:
-
Write a function called
listTodos
:- When called, it should iterate over the items in the
TODOS
array. - If the item is not done, print it out. If it's done, skip it.
- You should print the item's index and title, like this:
0 - Clean bedroom 2 - Do homework 3 - Make dinner
- When called, it should iterate over the items in the
-
Write a function called
addTodo
:- When called, it should prompt the user to enter the task.
- Make a new item object containing properties called
title
anddone
. - Store the user's input in the title property and store
false
in the done property. - Now add the item object to the end of the
TODOS
array.
-
Write a function called
completeTodo
:- When called, it should prompt the user to enter the index of a task.
- Using the index, find that todo item in the
TODOS
array. - Then update that item's
done
property to betrue
. - For example, if the user enters
0
, the first item should be marked complete.
Once you have these three functions working, you should add one extra feature of your choice. Maybe that feature is a separate command and function, or maybe it's an addition or modification to the three you already wrote. Some ideas: you could add a date property, you could sort the items differently while listing, etc. Think about how it could be better if you were using it.
Grading
- 10 pts for well commented code.
- 10 pts for following the requirements.
- 5 pts for a program that runs without errors.
- 5 pts for following code style guidelines.
Total: 30 pts